summaryrefslogtreecommitdiff
path: root/internal/cli/status.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli/status.go')
-rw-r--r--internal/cli/status.go63
1 files changed, 63 insertions, 0 deletions
diff --git a/internal/cli/status.go b/internal/cli/status.go
new file mode 100644
index 0000000..4613fee
--- /dev/null
+++ b/internal/cli/status.go
@@ -0,0 +1,63 @@
+package cli
+
+import (
+ "fmt"
+ "os"
+ "text/tabwriter"
+
+ "github.com/claudomator/claudomator/internal/storage"
+ "github.com/spf13/cobra"
+)
+
+func newStatusCmd() *cobra.Command {
+ cmd := &cobra.Command{
+ Use: "status <task-id>",
+ Short: "Show task status and execution history",
+ Args: cobra.ExactArgs(1),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return showStatus(args[0])
+ },
+ }
+ return cmd
+}
+
+func showStatus(id string) error {
+ store, err := storage.Open(cfg.DBPath)
+ if err != nil {
+ return fmt.Errorf("opening db: %w", err)
+ }
+ defer store.Close()
+
+ // Try full ID first, then prefix match.
+ t, err := store.GetTask(id)
+ if err != nil {
+ return fmt.Errorf("task %q not found", id)
+ }
+
+ fmt.Printf("Task: %s\n", t.Name)
+ fmt.Printf("ID: %s\n", t.ID)
+ fmt.Printf("State: %s\n", t.State)
+ fmt.Printf("Priority: %s\n", t.Priority)
+ fmt.Printf("Model: %s\n", t.Claude.Model)
+ if t.Description != "" {
+ fmt.Printf("Description: %s\n", t.Description)
+ }
+
+ execs, err := store.ListExecutions(t.ID)
+ if err != nil {
+ return err
+ }
+
+ if len(execs) > 0 {
+ fmt.Printf("\nExecutions (%d):\n", len(execs))
+ w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
+ fmt.Fprintln(w, " ID\tSTATUS\tEXIT\tCOST\tDURATION\tSTARTED")
+ for _, e := range execs {
+ dur := e.EndTime.Sub(e.StartTime)
+ fmt.Fprintf(w, " %.8s\t%s\t%d\t$%.4f\t%v\t%s\n",
+ e.ID, e.Status, e.ExitCode, e.CostUSD, dur.Round(1e9), e.StartTime.Format("15:04:05"))
+ }
+ w.Flush()
+ }
+ return nil
+}