Skip to content

Commit 69906b5

Browse files
fix: fix CLI_ARGS completion for fish and zsh (#1843)
1 parent ad5a316 commit 69906b5

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

completion/fish/task.fish

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ function __task_get_tasks --description "Prints all available tasks with their d
1616
end
1717
end
1818

19-
complete -c $GO_TASK_PROGNAME -d 'Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was
20-
specified.' -xa "(__task_get_tasks)"
19+
complete -c $GO_TASK_PROGNAME \
20+
-d 'Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was specified.' \
21+
-xa "(__task_get_tasks)" \
22+
-n "not __fish_seen_subcommand_from --"
2123

2224
complete -c $GO_TASK_PROGNAME -s c -l color -d 'colored output (default true)'
2325
complete -c $GO_TASK_PROGNAME -s d -l dir -d 'sets directory of execution'

completion/zsh/_task

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ function __task_list() {
1414
taskfile=${(Qv)opt_args[(i)-t|--taskfile]}
1515
taskfile=${taskfile//\~/$HOME}
1616

17+
for arg in "${words[@]:0:$CURRENT}"; do
18+
if [[ "$arg" = "--" ]]; then
19+
# Use default completion for words after `--` as they are CLI_ARGS.
20+
_default
21+
return 0
22+
fi
23+
done
1724

1825
if [[ -n "$taskfile" && -f "$taskfile" ]]; then
1926
enabled=1
@@ -40,6 +47,7 @@ function __task_list() {
4047

4148
_task() {
4249
_arguments \
50+
-S \
4351
'(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: ' \
4452
'(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]' \
4553
'(-f --force)'{-f,--force}'[run even if task is up-to-date]' \
@@ -55,13 +63,13 @@ _task() {
5563
'(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files' \
5664
'(-v --verbose)'{-v,--verbose}'[verbose mode]' \
5765
'(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]' \
66+
'(operation)*: :__task_list' \
5867
+ '(operation)' \
59-
{-l,--list}'[list describable tasks]' \
60-
{-a,--list-all}'[list all tasks]' \
61-
{-i,--init}'[create new Taskfile.yml]' \
62-
'(-*)'{-h,--help}'[show help]' \
63-
'(-*)--version[show version and exit]' \
64-
'*: :__task_list'
68+
'(*)'{-l,--list}'[list describable tasks]' \
69+
'(*)'{-a,--list-all}'[list all tasks]' \
70+
'(*)'{-i,--init}'[create new Taskfile.yml]' \
71+
'(- *)'{-h,--help}'[show help]' \
72+
'(- *)--version[show version and exit]' \
6573
}
6674

6775
# don't run the completion function when being source-ed or eval-ed

0 commit comments

Comments
 (0)