@@ -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