summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-22 07:34:15 +0200
committerPaul Buetow <paul@buetow.org>2026-03-22 07:34:15 +0200
commitf00dfc0289027d7930bf4284f13046be5aee34c6 (patch)
treec797458cc84e97c9113c2f62d8fd4ea6faa93bac /cmd
parent42ccd63c544fdad033df6e7644472008987def74 (diff)
Remove 'hexai task' subcommand; task management is fully handled by the 'ask' command
Amp-Thread-ID: https://ampcode.com/threads/T-019d1407-6145-7534-b780-29a2559d06c5 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hexai/app_runner.go21
-rw-r--r--cmd/hexai/app_runner_test.go44
-rw-r--r--cmd/hexai/task_command.go16
-rw-r--r--cmd/hexai/task_command_test.go14
4 files changed, 10 insertions, 85 deletions
diff --git a/cmd/hexai/app_runner.go b/cmd/hexai/app_runner.go
index cf1ed3a..ab1766b 100644
--- a/cmd/hexai/app_runner.go
+++ b/cmd/hexai/app_runner.go
@@ -18,12 +18,9 @@ type configLoader func(string) appconfig.App
type cliRunner func(context.Context, []string, io.Reader, io.Writer, io.Writer) error
-type taskSubcommandRunner func([]string, io.Reader, io.Writer, io.Writer) (bool, int, error)
-
type appRunner struct {
- loadConfig configLoader
- runCLI cliRunner
- runTaskSubcommand taskSubcommandRunner
+ loadConfig configLoader
+ runCLI cliRunner
}
type parsedAppArgs struct {
@@ -36,9 +33,8 @@ type parsedAppArgs struct {
func newAppRunner() appRunner {
return appRunner{
- loadConfig: loadAppConfig,
- runCLI: hexaicli.Run,
- runTaskSubcommand: runTaskSubcommandIfRequested,
+ loadConfig: loadAppConfig,
+ runCLI: hexaicli.Run,
}
}
@@ -54,12 +50,6 @@ func (r appRunner) run(args []string, stdin io.Reader, stdout, stderr io.Writer)
fmt.Fprintln(stdout, internal.Version)
return 0
}
- if handled, exitCode, err := runner.runTaskSubcommand(parsed.args, stdin, stdout, stderr); handled {
- if err != nil {
- fmt.Fprintln(stderr, err)
- }
- return exitCode
- }
ctx := buildCLIContext(parsed)
if err := runner.runCLI(ctx, parsed.args, stdin, stdout, stderr); err != nil {
return 1
@@ -74,9 +64,6 @@ func normalizeAppRunner(r appRunner) appRunner {
if r.runCLI == nil {
r.runCLI = hexaicli.Run
}
- if r.runTaskSubcommand == nil {
- r.runTaskSubcommand = runTaskSubcommandIfRequested
- }
return r
}
diff --git a/cmd/hexai/app_runner_test.go b/cmd/hexai/app_runner_test.go
index 2f03210..ce0c8fe 100644
--- a/cmd/hexai/app_runner_test.go
+++ b/cmd/hexai/app_runner_test.go
@@ -11,7 +11,7 @@ import (
"codeberg.org/snonux/hexai/internal/appconfig"
)
-func TestAppRunnerRun_TaskDispatchAfterConfigFlag(t *testing.T) {
+func TestAppRunnerRun_ConfigFlagPassedToLoader(t *testing.T) {
var gotConfigPath string
var gotArgs []string
runner := appRunner{
@@ -19,53 +19,21 @@ func TestAppRunnerRun_TaskDispatchAfterConfigFlag(t *testing.T) {
gotConfigPath = path
return appconfig.App{}
},
- runCLI: func(context.Context, []string, io.Reader, io.Writer, io.Writer) error {
- t.Fatal("runCLI should not be called when task subcommand is handled")
- return nil
- },
- runTaskSubcommand: func(args []string, stdin io.Reader, stdout, stderr io.Writer) (bool, int, error) {
+ runCLI: func(_ context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error {
gotArgs = append([]string(nil), args...)
- return true, 0, nil
+ return nil
},
}
- exitCode := runner.run([]string{"--config", "/tmp/hexai.toml", "task", "list"}, strings.NewReader(""), &bytes.Buffer{}, &bytes.Buffer{})
+ exitCode := runner.run([]string{"--config", "/tmp/hexai.toml", "hello"}, strings.NewReader(""), &bytes.Buffer{}, &bytes.Buffer{})
if exitCode != 0 {
t.Fatalf("exitCode = %d, want 0", exitCode)
}
if gotConfigPath != "/tmp/hexai.toml" {
t.Fatalf("configPath = %q, want /tmp/hexai.toml", gotConfigPath)
}
- wantArgs := []string{"task", "list"}
+ wantArgs := []string{"hello"}
if !reflect.DeepEqual(gotArgs, wantArgs) {
- t.Fatalf("task args = %v, want %v", gotArgs, wantArgs)
- }
-}
-
-func TestAppRunnerRun_SingleArgumentTaskListFallsThroughToCLI(t *testing.T) {
- var taskArgs []string
- var cliArgs []string
- runner := appRunner{
- loadConfig: func(string) appconfig.App { return appconfig.App{} },
- runCLI: func(_ context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error {
- cliArgs = append([]string(nil), args...)
- return nil
- },
- runTaskSubcommand: func(args []string, stdin io.Reader, stdout, stderr io.Writer) (bool, int, error) {
- taskArgs = append([]string(nil), args...)
- return false, 0, nil
- },
- }
-
- exitCode := runner.run([]string{"task list"}, strings.NewReader(""), &bytes.Buffer{}, &bytes.Buffer{})
- if exitCode != 0 {
- t.Fatalf("exitCode = %d, want 0", exitCode)
- }
- wantArgs := []string{"task list"}
- if !reflect.DeepEqual(taskArgs, wantArgs) {
- t.Fatalf("task dispatch args = %v, want %v", taskArgs, wantArgs)
- }
- if !reflect.DeepEqual(cliArgs, wantArgs) {
- t.Fatalf("cli args = %v, want %v", cliArgs, wantArgs)
+ t.Fatalf("cli args = %v, want %v", gotArgs, wantArgs)
}
}
diff --git a/cmd/hexai/task_command.go b/cmd/hexai/task_command.go
deleted file mode 100644
index a942f71..0000000
--- a/cmd/hexai/task_command.go
+++ /dev/null
@@ -1,16 +0,0 @@
-package main
-
-import (
- "context"
- "io"
-
- "codeberg.org/snonux/hexai/internal/taskproxy"
-)
-
-func runTaskSubcommandIfRequested(args []string, stdin io.Reader, stdout, stderr io.Writer) (bool, int, error) {
- if len(args) == 0 || args[0] != "task" {
- return false, 0, nil
- }
- code, err := taskproxy.NewRunner("hexai task").Run(context.Background(), args[1:], stdin, stdout, stderr)
- return true, code, err
-}
diff --git a/cmd/hexai/task_command_test.go b/cmd/hexai/task_command_test.go
deleted file mode 100644
index 2cdf0bc..0000000
--- a/cmd/hexai/task_command_test.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package main
-
-import (
- "bytes"
- "strings"
- "testing"
-)
-
-func TestRunTaskSubcommandIfRequested_SkipsNonTaskArgs(t *testing.T) {
- handled, exitCode, err := runTaskSubcommandIfRequested([]string{"hello"}, strings.NewReader(""), &bytes.Buffer{}, &bytes.Buffer{})
- if handled || exitCode != 0 || err != nil {
- t.Fatalf("expected non-task args to be ignored, got handled=%v exitCode=%d err=%v", handled, exitCode, err)
- }
-}