summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-05 17:41:52 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-05 17:41:52 +0000
commitf7c6de4f99649dfa19c6b20b5a3fb344c4f8e82c (patch)
treeeee4a4a1e33f07194412f84fde17f7464b6430e2 /internal/cli
parentddfb922584dd990481f44aad1a989e5bdf188823 (diff)
cli: add start command and version package
Adds `claudomator start <task-id>` to queue a task via the running API server. Adds internal/version for embedding VCS commit hash in the server banner. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/root.go1
-rw-r--r--internal/cli/serve.go3
-rw-r--r--internal/cli/start.go44
3 files changed, 47 insertions, 1 deletions
diff --git a/internal/cli/root.go b/internal/cli/root.go
index 43f5cb9..75ec393 100644
--- a/internal/cli/root.go
+++ b/internal/cli/root.go
@@ -41,6 +41,7 @@ func NewRootCmd() *cobra.Command {
newStatusCmd(),
newInitCmd(),
newLogsCmd(),
+ newStartCmd(),
)
return cmd
diff --git a/internal/cli/serve.go b/internal/cli/serve.go
index 9545f5c..363e276 100644
--- a/internal/cli/serve.go
+++ b/internal/cli/serve.go
@@ -13,6 +13,7 @@ import (
"github.com/thepeterstone/claudomator/internal/api"
"github.com/thepeterstone/claudomator/internal/executor"
"github.com/thepeterstone/claudomator/internal/storage"
+ "github.com/thepeterstone/claudomator/internal/version"
"github.com/spf13/cobra"
)
@@ -83,7 +84,7 @@ func serve(addr string) error {
httpSrv.Shutdown(shutdownCtx)
}()
- fmt.Printf("Claudomator server listening on %s\n", addr)
+ fmt.Printf("Claudomator %s listening on %s\n", version.Version(), addr)
if err := httpSrv.ListenAndServe(); err != http.ErrServerClosed {
return err
}
diff --git a/internal/cli/start.go b/internal/cli/start.go
new file mode 100644
index 0000000..6ec09b2
--- /dev/null
+++ b/internal/cli/start.go
@@ -0,0 +1,44 @@
+package cli
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+
+ "github.com/spf13/cobra"
+)
+
+func newStartCmd() *cobra.Command {
+ var serverURL string
+
+ cmd := &cobra.Command{
+ Use: "start <task-id>",
+ Short: "Queue a task for execution via the running server",
+ Args: cobra.ExactArgs(1),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return startTask(serverURL, args[0])
+ },
+ }
+
+ cmd.Flags().StringVar(&serverURL, "server", "http://localhost:8484", "claudomator server URL")
+ return cmd
+}
+
+func startTask(serverURL, id string) error {
+ url := fmt.Sprintf("%s/api/tasks/%s/run", serverURL, id)
+ resp, err := http.Post(url, "application/json", nil) //nolint:noctx
+ if err != nil {
+ return fmt.Errorf("POST %s: %w", url, err)
+ }
+ defer resp.Body.Close()
+
+ var body map[string]string
+ _ = json.NewDecoder(resp.Body).Decode(&body)
+
+ if resp.StatusCode >= 300 {
+ return fmt.Errorf("server returned %d: %s", resp.StatusCode, body["error"])
+ }
+
+ fmt.Printf("Queued task %s\n", id)
+ return nil
+}