Skip to content

Commit dbc76d4

Browse files
committed
fix zsh
1 parent ce311cd commit dbc76d4

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

completion/fish/task.fish

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ if __task_is_experiment_enabled GENTLE_FORCE
8282
end
8383

8484
if __task_is_experiment_enabled REMOTE_TASKFILES
85-
complete -c $GO_TASK_PROGNAME -l download -d 'download remote Taskfile'
85+
# Options
8686
complete -c $GO_TASK_PROGNAME -l offline -d 'use only local or cached Taskfiles'
8787
complete -c $GO_TASK_PROGNAME -l timeout -d 'timeout for remote Taskfile downloads'
88-
complete -c $GO_TASK_PROGNAME -l clear-cache -d 'clear remote Taskfile cache'
8988
complete -c $GO_TASK_PROGNAME -l expiry -d 'cache expiry duration'
89+
# Operations
90+
complete -c $GO_TASK_PROGNAME -l download -d 'download remote Taskfile'
91+
complete -c $GO_TASK_PROGNAME -l clear-cache -d 'clear remote Taskfile cache'
9092
end

completion/ps/task.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ Register-ArgumentCompleter -CommandName task -ScriptBlock {
6868
}
6969

7070
if ($experiments -match '\* REMOTE_TASKFILES:.*on') {
71-
$completions += [CompletionResult]::new('--download', '--download', [CompletionResultType]::ParameterName, 'download remote Taskfile')
71+
# Options
7272
$completions += [CompletionResult]::new('--offline', '--offline', [CompletionResultType]::ParameterName, 'use cached Taskfiles')
7373
$completions += [CompletionResult]::new('--timeout', '--timeout', [CompletionResultType]::ParameterName, 'download timeout')
74-
$completions += [CompletionResult]::new('--clear-cache', '--clear-cache', [CompletionResultType]::ParameterName, 'clear cache')
7574
$completions += [CompletionResult]::new('--expiry', '--expiry', [CompletionResultType]::ParameterName, 'cache expiry')
75+
# Operations
76+
$completions += [CompletionResult]::new('--download', '--download', [CompletionResultType]::ParameterName, 'download remote Taskfile')
77+
$completions += [CompletionResult]::new('--clear-cache', '--clear-cache', [CompletionResultType]::ParameterName, 'clear cache')
7678
}
7779

7880
return $completions.Where{ $_.CompletionText.StartsWith($commandName) }

completion/zsh/_task

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ function __task_list() {
4242
}
4343

4444
_task() {
45-
local -a args
46-
args=(
45+
local -a standard_args operation_args
46+
47+
standard_args=(
4748
'(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: '
4849
'(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]'
4950
'(-f --force)'{-f,--force}'[run even if task is up-to-date]'
@@ -72,31 +73,43 @@ _task() {
7273
'(-v --verbose)'{-v,--verbose}'[verbose mode]'
7374
'(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]'
7475
'(-y --yes)'{-y,--yes}'[assume yes to all prompts]'
75-
+ '(operation)'
76-
{-l,--list}'[list describable tasks]'
77-
{-a,--list-all}'[list all tasks]'
78-
{-i,--init}'[create new Taskfile.yml]'
79-
'(-*)'{-h,--help}'[show help]'
80-
'(-*)--version[show version and exit]'
81-
'*: :__task_list'
8276
)
8377

8478
# Experimental flags (dynamically added based on enabled experiments)
79+
# Options (modify behavior)
8580
if __task_is_experiment_enabled "GENTLE_FORCE"; then
86-
args+=('(--force-all)--force-all[force execution of task and all dependencies]')
81+
standard_args+=('(--force-all)--force-all[force execution of task and all dependencies]')
8782
fi
8883

8984
if __task_is_experiment_enabled "REMOTE_TASKFILES"; then
90-
args+=(
91-
'(--download)--download[download remote Taskfile]'
85+
standard_args+=(
9286
'(--offline)--offline[use only local or cached Taskfiles]'
9387
'(--timeout)--timeout[timeout for remote Taskfile downloads]:duration: '
94-
'(--clear-cache)--clear-cache[clear remote Taskfile cache]'
9588
'(--expiry)--expiry[cache expiry duration]:duration: '
9689
)
9790
fi
9891

99-
_arguments $args
92+
operation_args=(
93+
+ '(operation)'
94+
{-l,--list}'[list describable tasks]'
95+
{-a,--list-all}'[list all tasks]'
96+
{-i,--init}'[create new Taskfile.yml]'
97+
'(-*)'{-h,--help}'[show help]'
98+
'(-*)--version[show version and exit]'
99+
)
100+
101+
# Experimental operations (dynamically added based on enabled experiments)
102+
if __task_is_experiment_enabled "REMOTE_TASKFILES"; then
103+
operation_args+=(
104+
'--download[download remote Taskfile]'
105+
'--clear-cache[clear remote Taskfile cache]'
106+
)
107+
fi
108+
109+
# Task names completion (must be last)
110+
operation_args+=('*: :__task_list')
111+
112+
_arguments $standard_args $operation_args
100113
}
101114

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

0 commit comments

Comments
 (0)