summaryrefslogtreecommitdiff
path: root/internal/cli/report.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-08 21:03:50 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-08 21:03:50 +0000
commit632ea5a44731af94b6238f330a3b5440906c8ae7 (patch)
treed8c780412598d66b89ef390b5729e379fdfd9d5b /internal/cli/report.go
parent406247b14985ab57902e8e42898dc8cb8960290d (diff)
parent93a4c852bf726b00e8014d385165f847763fa214 (diff)
merge: pull latest from master and resolve conflicts
- Resolve conflicts in API server, CLI, and executor. - Maintain Gemini classification and assignment logic. - Update UI to use generic agent config and project_dir. - Fix ProjectDir/WorkingDir inconsistencies in Gemini runner. - All tests passing after merge.
Diffstat (limited to 'internal/cli/report.go')
-rw-r--r--internal/cli/report.go74
1 files changed, 74 insertions, 0 deletions
diff --git a/internal/cli/report.go b/internal/cli/report.go
new file mode 100644
index 0000000..7f95c80
--- /dev/null
+++ b/internal/cli/report.go
@@ -0,0 +1,74 @@
+package cli
+
+import (
+ "fmt"
+ "os"
+ "time"
+
+ "github.com/spf13/cobra"
+ "github.com/thepeterstone/claudomator/internal/reporter"
+ "github.com/thepeterstone/claudomator/internal/storage"
+)
+
+func newReportCmd() *cobra.Command {
+ var format string
+ var limit int
+ var taskID string
+
+ cmd := &cobra.Command{
+ Use: "report",
+ Short: "Report execution history",
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return runReport(format, limit, taskID)
+ },
+ }
+
+ cmd.Flags().StringVar(&format, "format", "table", "output format: table, json, html")
+ cmd.Flags().IntVar(&limit, "limit", 50, "maximum number of executions to show")
+ cmd.Flags().StringVar(&taskID, "task", "", "filter by task ID")
+
+ return cmd
+}
+
+func runReport(format string, limit int, taskID string) error {
+ var rep reporter.Reporter
+ switch format {
+ case "table", "":
+ rep = &reporter.ConsoleReporter{}
+ case "json":
+ rep = &reporter.JSONReporter{Pretty: true}
+ case "html":
+ rep = &reporter.HTMLReporter{}
+ default:
+ return fmt.Errorf("invalid format %q: must be table, json, or html", format)
+ }
+
+ store, err := storage.Open(cfg.DBPath)
+ if err != nil {
+ return fmt.Errorf("opening db: %w", err)
+ }
+ defer store.Close()
+
+ recent, err := store.ListRecentExecutions(time.Time{}, limit, taskID)
+ if err != nil {
+ return fmt.Errorf("listing executions: %w", err)
+ }
+
+ execs := make([]*storage.Execution, len(recent))
+ for i, r := range recent {
+ e := &storage.Execution{
+ ID: r.ID,
+ TaskID: r.TaskID,
+ Status: r.State,
+ StartTime: r.StartedAt,
+ ExitCode: r.ExitCode,
+ CostUSD: r.CostUSD,
+ }
+ if r.FinishedAt != nil {
+ e.EndTime = *r.FinishedAt
+ }
+ execs[i] = e
+ }
+
+ return rep.Generate(os.Stdout, execs)
+}