Skip to content

Commit 84cc5e5

Browse files
authored
fix(completions): zsh and powershell completions (#1809)
1 parent 5aa68e4 commit 84cc5e5

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

completion/zsh/_task

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#compdef task
2-
3-
local context state state_descr line
2+
compdef _task task
43
typeset -A opt_args
54

65
_GO_TASK_COMPLETION_LIST_OPTION="${GO_TASK_COMPLETION_LIST_OPTION:---list-all}"
@@ -39,26 +38,33 @@ function __task_list() {
3938
_describe 'Task to run' scripts
4039
}
4140

42-
_arguments \
43-
'(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: ' \
44-
'(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]' \
45-
'(-f --force)'{-f,--force}'[run even if task is up-to-date]' \
46-
'(-c --color)'{-c,--color}'[colored output]' \
47-
'(-d --dir)'{-d,--dir}'[dir to run in]:execution dir:_dirs' \
48-
'(--dry)--dry[dry-run mode, compile and print tasks only]' \
49-
'(-o --output)'{-o,--output}'[set output style]:style:(interleaved group prefixed)' \
50-
'(--output-group-begin)--output-group-begin[message template before grouped output]:template text: ' \
51-
'(--output-group-end)--output-group-end[message template after grouped output]:template text: ' \
52-
'(-s --silent)'{-s,--silent}'[disable echoing]' \
53-
'(--status)--status[exit non-zero if supplied tasks not up-to-date]' \
54-
'(--summary)--summary[show summary\: field from tasks instead of running them]' \
55-
'(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files' \
56-
'(-v --verbose)'{-v,--verbose}'[verbose mode]' \
57-
'(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]' \
58-
+ '(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'
41+
_task() {
42+
_arguments \
43+
'(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: ' \
44+
'(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]' \
45+
'(-f --force)'{-f,--force}'[run even if task is up-to-date]' \
46+
'(-c --color)'{-c,--color}'[colored output]' \
47+
'(-d --dir)'{-d,--dir}'[dir to run in]:execution dir:_dirs' \
48+
'(--dry)--dry[dry-run mode, compile and print tasks only]' \
49+
'(-o --output)'{-o,--output}'[set output style]:style:(interleaved group prefixed)' \
50+
'(--output-group-begin)--output-group-begin[message template before grouped output]:template text: ' \
51+
'(--output-group-end)--output-group-end[message template after grouped output]:template text: ' \
52+
'(-s --silent)'{-s,--silent}'[disable echoing]' \
53+
'(--status)--status[exit non-zero if supplied tasks not up-to-date]' \
54+
'(--summary)--summary[show summary\: field from tasks instead of running them]' \
55+
'(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files' \
56+
'(-v --verbose)'{-v,--verbose}'[verbose mode]' \
57+
'(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]' \
58+
+ '(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'
65+
}
66+
67+
# don't run the completion function when being source-ed or eval-ed
68+
if [ "$funcstack[1]" = "_task" ]; then
69+
_task "$@"
70+
fi

website/docs/installation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ task --completion fish | source
287287

288288
<TabItem value="4">
289289
```powershell title="$PROFILE\Microsoft.PowerShell_profile.ps1"
290-
Invoke-Expression (&task --completion powershell)
290+
Invoke-Expression (&task --completion powershell | Out-String)
291291
```
292292
</TabItem></Tabs>
293293

0 commit comments

Comments
 (0)