From 69d3ec004b8de3b9f7cfeb34686b9c344c787db4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 11 Apr 2026 22:20:57 +0300 Subject: Rename task CLI binary from do back to ask - Move cmd/do to cmd/ask; mage builds and installs ask; Fish completions to ask.fish - Update askcli help text, errors, executor default label, and Fish script (__ask_*) - Task alias cache subdirectory under XDG cache: hexai/ask/ - Rename integration test files and helpers; refresh README and docs - Rename plan-do-uuid-wrapper.md to plan-ask-uuid-wrapper.md Made-with: Cursor --- cmd/ask/main.go | 22 ++++++++++++++++++++++ cmd/ask/main_test.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ cmd/do/main.go | 22 ---------------------- cmd/do/main_test.go | 51 --------------------------------------------------- 4 files changed, 73 insertions(+), 73 deletions(-) create mode 100644 cmd/ask/main.go create mode 100644 cmd/ask/main_test.go delete mode 100644 cmd/do/main.go delete mode 100644 cmd/do/main_test.go (limited to 'cmd') diff --git a/cmd/ask/main.go b/cmd/ask/main.go new file mode 100644 index 0000000..afab992 --- /dev/null +++ b/cmd/ask/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "context" + "fmt" + "os" + + "codeberg.org/snonux/hexai/internal/askcli" +) + +func main() { + d := askcli.NewDispatcher(nil) + code, err := d.Dispatch(context.Background(), os.Args[1:], os.Stdin, os.Stdout, os.Stderr) + if err != nil { + // Print the internal error so callers get a useful diagnostic message. + fmt.Fprintln(os.Stderr, err) + os.Exit(code) + } + if code != 0 { + os.Exit(code) + } +} diff --git a/cmd/ask/main_test.go b/cmd/ask/main_test.go new file mode 100644 index 0000000..db6b436 --- /dev/null +++ b/cmd/ask/main_test.go @@ -0,0 +1,51 @@ +package main + +import ( + "bytes" + "context" + "io" + "testing" + + "codeberg.org/snonux/hexai/internal/askcli" +) + +func TestMain_WiresDispatcher(t *testing.T) { + var gotArgs []string + d := askcli.NewDispatcher(&spyRunner{ + runFn: func(_ context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + gotArgs = append([]string(nil), args...) + io.WriteString(stdout, `[{"uuid":"test-uuid","description":"Test","status":"pending","priority":"H","tags":["cli"],"urgency":15.0,"depends":[]}]`) + return 0, nil + }, + }) + code, err := d.Dispatch(context.Background(), []string{"list", "limit:1"}, nil, &bytes.Buffer{}, &bytes.Buffer{}) + if err != nil { + t.Fatalf("dispatch returned error: %v", err) + } + if code != 0 { + t.Fatalf("exitCode = %d, want 0", code) + } + if len(gotArgs) < 1 || gotArgs[len(gotArgs)-1] != "export" { + t.Fatalf("args = %v, want [..., export]", gotArgs) + } +} + +func TestMain_ExitsNonZero(t *testing.T) { + d := askcli.NewDispatcher(&spyRunner{ + runFn: func(context.Context, []string, io.Reader, io.Writer, io.Writer) (int, error) { + return 1, nil + }, + }) + code, _ := d.Dispatch(context.Background(), []string{"list"}, nil, &bytes.Buffer{}, &bytes.Buffer{}) + if code == 0 { + t.Fatalf("exitCode = 0, want non-zero") + } +} + +type spyRunner struct { + runFn func(context.Context, []string, io.Reader, io.Writer, io.Writer) (int, error) +} + +func (s *spyRunner) Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + return s.runFn(ctx, args, stdin, stdout, stderr) +} diff --git a/cmd/do/main.go b/cmd/do/main.go deleted file mode 100644 index afab992..0000000 --- a/cmd/do/main.go +++ /dev/null @@ -1,22 +0,0 @@ -package main - -import ( - "context" - "fmt" - "os" - - "codeberg.org/snonux/hexai/internal/askcli" -) - -func main() { - d := askcli.NewDispatcher(nil) - code, err := d.Dispatch(context.Background(), os.Args[1:], os.Stdin, os.Stdout, os.Stderr) - if err != nil { - // Print the internal error so callers get a useful diagnostic message. - fmt.Fprintln(os.Stderr, err) - os.Exit(code) - } - if code != 0 { - os.Exit(code) - } -} diff --git a/cmd/do/main_test.go b/cmd/do/main_test.go deleted file mode 100644 index db6b436..0000000 --- a/cmd/do/main_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "bytes" - "context" - "io" - "testing" - - "codeberg.org/snonux/hexai/internal/askcli" -) - -func TestMain_WiresDispatcher(t *testing.T) { - var gotArgs []string - d := askcli.NewDispatcher(&spyRunner{ - runFn: func(_ context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { - gotArgs = append([]string(nil), args...) - io.WriteString(stdout, `[{"uuid":"test-uuid","description":"Test","status":"pending","priority":"H","tags":["cli"],"urgency":15.0,"depends":[]}]`) - return 0, nil - }, - }) - code, err := d.Dispatch(context.Background(), []string{"list", "limit:1"}, nil, &bytes.Buffer{}, &bytes.Buffer{}) - if err != nil { - t.Fatalf("dispatch returned error: %v", err) - } - if code != 0 { - t.Fatalf("exitCode = %d, want 0", code) - } - if len(gotArgs) < 1 || gotArgs[len(gotArgs)-1] != "export" { - t.Fatalf("args = %v, want [..., export]", gotArgs) - } -} - -func TestMain_ExitsNonZero(t *testing.T) { - d := askcli.NewDispatcher(&spyRunner{ - runFn: func(context.Context, []string, io.Reader, io.Writer, io.Writer) (int, error) { - return 1, nil - }, - }) - code, _ := d.Dispatch(context.Background(), []string{"list"}, nil, &bytes.Buffer{}, &bytes.Buffer{}) - if code == 0 { - t.Fatalf("exitCode = 0, want non-zero") - } -} - -type spyRunner struct { - runFn func(context.Context, []string, io.Reader, io.Writer, io.Writer) (int, error) -} - -func (s *spyRunner) Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { - return s.runFn(ctx, args, stdin, stdout, stderr) -} -- cgit v1.2.3