MCPcopy Create free account
hub / github.com/driangle/taskmd / runReport

Function runReport

apps/cli/internal/cli/report.go:59–111  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

57}
58
59func runReport(cmd *cobra.Command, args []string) error {
60 flags := GetGlobalFlags()
61
62 if err := ValidateFormat(reportFormat, []string{"md", "html", "json"}); err != nil {
63 return err
64 }
65
66 scanDir := ResolveScanDir(args)
67
68 taskScanner := scanner.NewScanner(scanDir, flags.Verbose, flags.IgnoreDirs)
69 result, err := taskScanner.Scan()
70 if err != nil {
71 return fmt.Errorf("scan failed: %w", err)
72 }
73
74 if flags.Verbose && len(result.Errors) > 0 {
75 fmt.Fprintf(os.Stderr, "\nWarning: encountered %d errors during scan:\n", len(result.Errors))
76 for _, scanErr := range result.Errors {
77 fmt.Fprintf(os.Stderr, " %s: %v\n", scanErr.FilePath, scanErr.Error)
78 }
79 fmt.Fprintln(os.Stderr)
80 }
81
82 warnDuplicateIDs(result.Tasks)
83
84 data, err := collectReportData(result.Tasks, reportGroupBy, reportIncludeGraph)
85 if err != nil {
86 return err
87 }
88
89 var outFile *os.File
90 if reportOut != "" {
91 f, err := os.Create(reportOut)
92 if err != nil {
93 return fmt.Errorf("failed to create output file: %w", err)
94 }
95 defer f.Close()
96 outFile = f
97 } else {
98 outFile = os.Stdout
99 }
100
101 switch reportFormat {
102 case "md":
103 return outputReportMarkdown(data, outFile)
104 case "html":
105 return outputReportHTML(data, outFile)
106 case "json":
107 return outputReportJSON(data, outFile)
108 default:
109 return fmt.Errorf("unsupported format: %s", reportFormat)
110 }
111}
112
113// ReportTaskJSON is the JSON representation of a task in report sections.
114type ReportTaskJSON struct {

Calls 9

ScanMethod · 0.95
GetGlobalFlagsFunction · 0.85
ValidateFormatFunction · 0.85
ResolveScanDirFunction · 0.85
warnDuplicateIDsFunction · 0.85
collectReportDataFunction · 0.85
outputReportMarkdownFunction · 0.85
outputReportHTMLFunction · 0.85
outputReportJSONFunction · 0.85