Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions cmd/cmd_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func runReportCmd(cmd *cobra.Command, args []string) {
reportGenerator := pulse.NewReportGenerator(scoreCalculator, thresholdLabelType)

// Generate the report
var reportContent string
var reportOutput *pulse.ReportOutput
var reportErr error

reportFormat := pulse.TextFormat
Expand All @@ -83,12 +83,14 @@ func runReportCmd(cmd *cobra.Command, args []string) {
reportFormat = pulse.JSONFormat
case "table":
reportFormat = pulse.TableFormat
case "pdf":
reportFormat = pulse.PDFFormat
}

if category != "" {
reportContent, reportErr = reportGenerator.GenerateCategoryReport(category, reportFormat)
reportOutput, reportErr = reportGenerator.GenerateCategoryReport(category, reportFormat)
} else {
reportContent, reportErr = reportGenerator.GenerateOverallReport(reportFormat)
reportOutput, reportErr = reportGenerator.GenerateOverallReport(reportFormat)
}

if reportErr != nil {
Expand All @@ -103,13 +105,18 @@ func runReportCmd(cmd *cobra.Command, args []string) {

// Output the report
if outputFile != "" {
err := os.WriteFile(outputFile, []byte(reportContent), 0600)
err := os.WriteFile(outputFile, reportOutput.Content, 0600)
if err != nil {
fmt.Printf("Error writing report to file: %v\n", err)
os.Exit(1)
}
fmt.Printf("Report written to %s\n", outputFile)
} else {
fmt.Println(reportContent)
if reportOutput.ContentType == "binary" {
fmt.Println("PDF output requires an output file. Please specify one with --output/-o flag.")
os.Exit(1)
} else {
fmt.Println(string(reportOutput.Content))
}
}
}
2 changes: 1 addition & 1 deletion cmd/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func setupFlags(defaultConfigDir, defaultDataDir string) {
rootCmd.PersistentFlags().StringVar(&dataDir, "data-dir", defaultDataDir, "Directory containing data files")

reportCmd.Flags().StringVarP(&category, "category", "c", "", "Generate report for a specific category")
reportCmd.Flags().StringVarP(&format, "format", "f", "text", "Report format (text, json, or table)")
reportCmd.Flags().StringVarP(&format, "format", "f", "text", "Report format (text, json, table, or pdf)")
reportCmd.Flags().StringVarP(&outputFile, "output", "o", "", "Output file (default: stdout)")
reportCmd.Flags().StringVar(&scoringMethod, "scoring-method", "median", "Scoring method to use (median or average)")
reportCmd.Flags().StringVar(&thresholdLabels, "threshold-labels", "emoji", "Threshold label format (emoji or text)")
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.24.2

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/phpdave11/gofpdf v1.4.3 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/phpdave11/gofpdf v1.4.3 h1:M/zHvS8FO3zh9tUd2RCOPEjyuVcs281FCyF22Qlz/IA=
github.com/phpdave11/gofpdf v1.4.3/go.mod h1:MAwzoUIgD3J55u0rxIG2eu37c+XWhBtXSpPAhnQXf/o=
github.com/phpdave11/gofpdi v1.0.15/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading