From 9dc8c5e241af77fd61c1da91e0fe49faa5cf06e4 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 26 Mar 2026 22:21:34 +0200 Subject: ask: filter fish UUID completion --- assets/ask.fish | 2 +- docs/fish-completion.md | 2 +- internal/askcli/completion.go | 2 +- internal/askcli/completion_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/ask.fish b/assets/ask.fish index 6c5f904..68fcf9f 100644 --- a/assets/ask.fish +++ b/assets/ask.fish @@ -92,7 +92,7 @@ function __ask_in_dep_uuid_context end function __ask_task_uuids - command ask all --json 2>/dev/null | string match -r -a -g '"uuid":"([^"]+)"' + command ask all --json 2>/dev/null | jq -r '.[] | select(.status != "completed" and .status != "deleted") | .uuid' 2>/dev/null end complete -c ask -f diff --git a/docs/fish-completion.md b/docs/fish-completion.md index b37b79d..10966e9 100644 --- a/docs/fish-completion.md +++ b/docs/fish-completion.md @@ -3,7 +3,7 @@ Hexai ships a Fish completion file for the `ask` task-management CLI at [`assets/ask.fish`](../assets/ask.fish). It completes the top-level `ask` subcommands and the nested `ask dep` operations. -It also completes task UUIDs for UUID-taking commands by reading the current project from `ask all --json`. +It also completes task UUIDs for UUID-taking commands by reading the current project from `ask all --json` and filtering out completed and deleted tasks. The script preserves the global `--json` flag. Install it into Fish's completion directory: diff --git a/internal/askcli/completion.go b/internal/askcli/completion.go index 28ad306..e947495 100644 --- a/internal/askcli/completion.go +++ b/internal/askcli/completion.go @@ -189,7 +189,7 @@ func writeFishDepUUIDContextFunction(b *strings.Builder) { func writeFishTaskUUIDFunction(b *strings.Builder) { b.WriteString("function __ask_task_uuids\n") - b.WriteString(" command ask all --json 2>/dev/null | string match -r -a -g '\"uuid\":\"([^\"]+)\"'\n") + b.WriteString(" command ask all --json 2>/dev/null | jq -r '.[] | select(.status != \"completed\" and .status != \"deleted\") | .uuid' 2>/dev/null\n") b.WriteString("end\n\n") } diff --git a/internal/askcli/completion_test.go b/internal/askcli/completion_test.go index 439e483..52cdce8 100644 --- a/internal/askcli/completion_test.go +++ b/internal/askcli/completion_test.go @@ -36,7 +36,7 @@ func TestFishCompletion_IncludesCommandsAndExcludesExport(t *testing.T) { "complete -c ask -n '__ask_in_dep_context' -a 'rm' -d 'Remove a dependency'", "complete -c ask -n '__ask_in_dep_context' -a 'list' -d 'List dependencies'", "function __ask_task_uuids", - "command ask all --json 2>/dev/null", + "command ask all --json 2>/dev/null | jq -r '.[] | select(.status != \"completed\" and .status != \"deleted\") | .uuid' 2>/dev/null", "complete -c ask -n '__ask_in_uuid_context' -a '(__ask_task_uuids)' -d 'Show task details'", "complete -c ask -n '__ask_in_dep_uuid_context' -a '(__ask_task_uuids)' -d 'Add a dependency'", "complete -c ask -n '__ask_in_dep_uuid_context' -a '(__ask_task_uuids)' -d 'Remove a dependency'", -- cgit v1.2.3