feat(completion): unify shell completions behind an opt-in `task __complete` engine
Bash, Fish, Zsh, Nushell and PowerShell now share a single backend: `task __complete` returns the suggestions plus a directive, and every wrapper is a thin shim around it. All five shells offer the same suggestions — task names, aliases, flags, flag values and per-task CLI variables. The Zsh `show-aliases` and `verbose` zstyles keep working, now backed by the `--no-aliases` and `--no-descriptions` completion flags.
The engine is opt-in via `task --new-completion <shell>`, leaving `--completion` and the legacy scripts untouched; it will become the default in a future release. The new wrappers live under `completion/next/`.
Completing a keystroke never reaches the network, never blocks on a stdin entrypoint, and honors every flag that decides how the Taskfile is loaded. Ref resolution shared by `requires` and enum completion moved to `internal/refs`.
A cross-shell test suite exercises the protocol in Go with thin shell smoke tests, and runs in CI.
2026-08-20 13:56:01 +02:00
|
|
|
#!/usr/bin/env fish
|
|
|
|
|
# Smoke-tests how the fish wrapper routes each directive, via `complete -C`.
|
|
|
|
|
# Set up by run.sh: TASK_FIXTURE, and `task` on PATH = the binary under test.
|
|
|
|
|
|
|
|
|
|
cd $TASK_FIXTURE
|
2026-08-29 11:05:08 +02:00
|
|
|
source (dirname (status -f))/../../completion/fish/task.fish
|
feat(completion): unify shell completions behind an opt-in `task __complete` engine
Bash, Fish, Zsh, Nushell and PowerShell now share a single backend: `task __complete` returns the suggestions plus a directive, and every wrapper is a thin shim around it. All five shells offer the same suggestions — task names, aliases, flags, flag values and per-task CLI variables. The Zsh `show-aliases` and `verbose` zstyles keep working, now backed by the `--no-aliases` and `--no-descriptions` completion flags.
The engine is opt-in via `task --new-completion <shell>`, leaving `--completion` and the legacy scripts untouched; it will become the default in a future release. The new wrappers live under `completion/next/`.
Completing a keystroke never reaches the network, never blocks on a stdin entrypoint, and honors every flag that decides how the Taskfile is loaded. Ref resolution shared by `requires` and enum completion moved to `internal/refs`.
A cross-shell test suite exercises the protocol in Go with thin shell smoke tests, and runs in CI.
2026-08-20 13:56:01 +02:00
|
|
|
|
|
|
|
|
set -g fails 0
|
|
|
|
|
|
|
|
|
|
function cands
|
|
|
|
|
complete -C $argv[1] | string split -f1 \t
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function has # LABEL LINE VALUE
|
|
|
|
|
if contains -- $argv[3] (cands $argv[2])
|
|
|
|
|
echo " ok $argv[1]"
|
|
|
|
|
else
|
|
|
|
|
echo " FAIL $argv[1] — '$argv[3]' missing from: "(cands $argv[2])
|
|
|
|
|
set fails (math $fails + 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function hasnot # LABEL LINE VALUE
|
|
|
|
|
if contains -- $argv[3] (cands $argv[2])
|
|
|
|
|
echo " FAIL $argv[1] — '$argv[3]' should be absent"
|
|
|
|
|
set fails (math $fails + 1)
|
|
|
|
|
else
|
|
|
|
|
echo " ok $argv[1]"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
echo "fish: :4 (NoFileComp) forwards candidates, offers no files"
|
|
|
|
|
has "candidate forwarded" 'task ' build
|
|
|
|
|
hasnot "no file fallback" 'task ' notes.txt
|
|
|
|
|
|
|
|
|
|
echo "fish: :16 (FilterDirs) offers directories only"
|
|
|
|
|
has "dir offered" 'task --dir ' sub/
|
|
|
|
|
hasnot "no plain file" 'task --dir ' notes.txt
|
|
|
|
|
|
|
|
|
|
echo "fish: :8 (FilterFileExt) filters by extension"
|
|
|
|
|
has "matching file" 'task --taskfile ' Taskfile.yml
|
|
|
|
|
hasnot "non-matching file" 'task --taskfile ' notes.txt
|
|
|
|
|
|
|
|
|
|
echo "fish: :0 (Default) falls back to files"
|
|
|
|
|
has "file offered" 'task build -- ' notes.txt
|
|
|
|
|
|
|
|
|
|
echo "fish: inline --flag=path keeps the --flag= prefix"
|
|
|
|
|
has "inline nested" 'task --taskfile=sub/' --taskfile=sub/nested.yml
|
|
|
|
|
hasnot "inline non-matching" 'task --taskfile=' --taskfile=notes.txt
|
|
|
|
|
|
|
|
|
|
if test $fails -ne 0
|
|
|
|
|
echo "fish: $fails failure(s)"
|
|
|
|
|
exit 1
|
|
|
|
|
end
|
|
|
|
|
echo "fish: all passed"
|