From 66811bb5c21fa674b19767f34ff7d27004f838b4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 8 Apr 2026 10:17:56 +0300 Subject: fish: complete task selectors with short aliases only Add complete-aliases subcommand that emits tab-separated alias lines without UUID duplicates. Wire embedded Fish script (__do_task_selectors) to call complete-aliases; keep complete-uuids unchanged for scripts and tests. Made-with: Cursor --- internal/askcli/dispatch_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'internal/askcli/dispatch_test.go') diff --git a/internal/askcli/dispatch_test.go b/internal/askcli/dispatch_test.go index 90c1b99..0e13788 100644 --- a/internal/askcli/dispatch_test.go +++ b/internal/askcli/dispatch_test.go @@ -90,6 +90,38 @@ func TestDispatcher_CompleteUUIDsSubcommand(t *testing.T) { } } +func TestDispatcher_CompleteAliasesSubcommand(t *testing.T) { + dir := t.TempDir() + oldRoot := taskAliasCacheRoot + oldNow := nowTaskAliasCache + taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil } + nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 27, 12, 0, 0, 0, time.UTC) } + defer func() { + taskAliasCacheRoot = oldRoot + nowTaskAliasCache = oldNow + }() + + d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + if strings.Join(args, " ") != "status:pending export" { + t.Fatalf("args = %v, want pending export", args) + } + _, _ = io.WriteString(stdout, `[{"uuid":"uuid-1","description":"Sample task"}]`) + return 0, nil + }}) + var stdout, stderr bytes.Buffer + code, err := d.Dispatch(context.Background(), []string{"complete-aliases"}, nil, &stdout, &stderr) + if err != nil { + t.Fatalf("complete-aliases returned error: %v", err) + } + if code != 0 { + t.Fatalf("complete-aliases code = %d, want 0", code) + } + // Fish completion uses aliases only; UUID lines are omitted. + if got := stdout.String(); got != "0\tSample task\n" { + t.Fatalf("stdout = %q, want alias-only tab-separated list", got) + } +} + func TestDispatcher_LongHelp(t *testing.T) { d := NewDispatcher(nil) var stdout bytes.Buffer @@ -322,6 +354,11 @@ func TestDispatcher_AllSubcommandsReachExecutor(t *testing.T) { args: []string{"complete-uuids"}, wantCalls: [][]string{{"status:pending", "export"}}, }, + { + name: "complete-aliases", + args: []string{"complete-aliases"}, + wantCalls: [][]string{{"status:pending", "export"}}, + }, { name: "info", args: []string{"info", "test-uuid"}, -- cgit v1.2.3