1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package cli
import (
"fmt"
"os"
"text/tabwriter"
"github.com/thepeterstone/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
}
|