diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-27 07:14:16 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-27 07:14:16 +0200 |
| commit | f146fbc4cc25bcdeab19a0c1055c839776cebff4 (patch) | |
| tree | 775bdf98d930b7f0fdd5bfe5ef0a31027b8e685d /internal/askcli/completion_test.go | |
| parent | 1d1d267c56b66af87b66b74c079cb211b9cf6d90 (diff) | |
askcli: support add depends selectors
Diffstat (limited to 'internal/askcli/completion_test.go')
| -rw-r--r-- | internal/askcli/completion_test.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/askcli/completion_test.go b/internal/askcli/completion_test.go index 14afdf5..fe18ddc 100644 --- a/internal/askcli/completion_test.go +++ b/internal/askcli/completion_test.go @@ -18,10 +18,12 @@ 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_selectors", + "function __ask_add_dependency_modifiers", `set -l ask_bin "ask"`, "set -l selectors (command $ask_bin complete-uuids 2>/dev/null)", "complete -c ask -n '__ask_in_uuid_context' -a '(__ask_task_selectors)' -d 'Task selector'", "complete -c ask -n '__ask_in_dep_uuid_context' -a '(__ask_task_selectors)' -d 'Task selector'", + "complete -c ask -n '__ask_in_add_dep_modifier_context' -a '(__ask_add_dependency_modifiers)' -d 'Task dependency'", } { if !strings.Contains(script, line) { t.Fatalf("script missing dep completion line %q", line) @@ -88,6 +90,29 @@ func TestFishDepSelectorCompletionContext(t *testing.T) { } } +func TestFishAddDependencyModifierCompletionContext(t *testing.T) { + testCases := []struct { + name string + positional []string + current string + want bool + }{ + {name: "add without depends modifier", positional: []string{"add", "task"}, current: "task", want: false}, + {name: "add with depends keyword prefix", positional: []string{"add"}, current: "depends", want: true}, + {name: "add with depends modifier", positional: []string{"add", "+cli"}, current: "depends:0", want: true}, + {name: "add with comma continuation", positional: []string{"add", "+cli"}, current: "depends:0,", want: true}, + {name: "non add command", positional: []string{"dep", "add"}, current: "depends:0", want: false}, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + if got := fishAddDependencyModifierCompletionContext(tc.positional, tc.current); got != tc.want { + t.Fatalf("fishAddDependencyModifierCompletionContext(%v, %q) = %t, want %t", tc.positional, tc.current, got, tc.want) + } + }) + } +} + func TestFishCompletionFor_EmbedsBinaryPath(t *testing.T) { script := FishCompletionFor(`/tmp/ask "$HOME"`) for _, line := range []string{ |
