summaryrefslogtreecommitdiff
path: root/internal/cli/list.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-02-08 21:35:45 -1000
committerPeter Stone <thepeterstone@gmail.com>2026-02-08 21:35:45 -1000
commit2e2b2187b957e9af78797a67ec5c6874615fae02 (patch)
tree1181dbb7e43f5d30cb025fa4d50fd4e7a2c893b3 /internal/cli/list.go
Initial project: task model, executor, API server, CLI, storage, reporter
Claudomator automation toolkit for Claude Code with: - Task model with YAML parsing, validation, state machine (49 tests, 0 races) - SQLite storage for tasks and executions - Executor pool with bounded concurrency, timeout, cancellation - REST API + WebSocket for mobile PWA integration - Webhook/multi-notifier system - CLI: init, run, serve, list, status commands - Console, JSON, HTML reporters with cost tracking Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli/list.go')
-rw-r--r--internal/cli/list.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/internal/cli/list.go b/internal/cli/list.go
new file mode 100644
index 0000000..a7515a1
--- /dev/null
+++ b/internal/cli/list.go
@@ -0,0 +1,59 @@
+package cli
+
+import (
+ "fmt"
+ "os"
+ "text/tabwriter"
+
+ "github.com/claudomator/claudomator/internal/storage"
+ "github.com/claudomator/claudomator/internal/task"
+ "github.com/spf13/cobra"
+)
+
+func newListCmd() *cobra.Command {
+ var state string
+
+ cmd := &cobra.Command{
+ Use: "list",
+ Short: "List tasks",
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return listTasks(state)
+ },
+ }
+
+ cmd.Flags().StringVar(&state, "state", "", "filter by state (PENDING, RUNNING, COMPLETED, FAILED)")
+
+ return cmd
+}
+
+func listTasks(state string) error {
+ store, err := storage.Open(cfg.DBPath)
+ if err != nil {
+ return fmt.Errorf("opening db: %w", err)
+ }
+ defer store.Close()
+
+ filter := storage.TaskFilter{}
+ if state != "" {
+ filter.State = task.State(state)
+ }
+
+ tasks, err := store.ListTasks(filter)
+ if err != nil {
+ return err
+ }
+
+ if len(tasks) == 0 {
+ fmt.Println("No tasks found.")
+ return nil
+ }
+
+ w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
+ fmt.Fprintln(w, "ID\tNAME\tSTATE\tPRIORITY\tCREATED")
+ for _, t := range tasks {
+ fmt.Fprintf(w, "%.8s\t%s\t%s\t%s\t%s\n",
+ t.ID, t.Name, t.State, t.Priority, t.CreatedAt.Format("2006-01-02 15:04"))
+ }
+ w.Flush()
+ return nil
+}