@@ -4,6 +4,12 @@ typeset -A opt_args
44
55_GO_TASK_COMPLETION_LIST_OPTION="${GO_TASK_COMPLETION_LIST_OPTION:---list-all}"
66
7+ # Check if an experiment is enabled
8+ function __task_is_experiment_enabled() {
9+ local experiment=$1
10+ task --experiments 2>/dev/null | grep -q "^\* ${experiment}:.*on"
11+ }
12+
713# Listing commands from Taskfile.yml
814function __task_list() {
915 local -a scripts cmd
@@ -36,51 +42,61 @@ function __task_list() {
3642}
3743
3844_task() {
39- _arguments \
40- '(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: ' \
41- '(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]' \
42- '(-f --force)'{-f,--force}'[run even if task is up-to-date]' \
43- '(-c --color)'{-c,--color}'[colored output]' \
44- '(--completion)--completion[generate shell completion script]:shell:(bash zsh fish powershell)' \
45- '(-d --dir)'{-d,--dir}'[dir to run in]:execution dir:_dirs' \
46- '(-n --dry)'{-n,--dry}'[compiles and prints tasks without executing]' \
47- '(--dry)--dry[dry-run mode, compile and print tasks only]' \
48- '(-x --exit-code)'{-x,--exit-code}'[pass-through exit code of task command]' \
49- '(--experiments)--experiments[list available experiments]' \
50- '(-g --global)'{-g,--global}'[run global Taskfile from home directory]' \
51- '(--insecure)--insecure[allow insecure Taskfile downloads]' \
52- '(-I --interval)'{-I,--interval}'[interval to watch for changes]:duration: ' \
53- '(-j --json)'{-j,--json}'[format task list as JSON]' \
54- '(--nested)--nested[nest namespaces when listing as JSON]' \
55- '(--no-status)--no-status[ignore status when listing as JSON]' \
56- '(-o --output)'{-o,--output}'[set output style]:style:(interleaved group prefixed)' \
57- '(--output-group-begin)--output-group-begin[message template before grouped output]:template text: ' \
58- '(--output-group-end)--output-group-end[message template after grouped output]:template text: ' \
59- '(--output-group-error-only)--output-group-error-only[hide output from successful tasks]' \
60- '(-s --silent)'{-s,--silent}'[disable echoing]' \
61- '(--sort)--sort[set task sorting order]:order:(default alphanumeric none)' \
62- '(--status)--status[exit non-zero if supplied tasks not up-to-date]' \
63- '(--summary)--summary[show summary\: field from tasks instead of running them]' \
64- '(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files' \
65- '(-v --verbose)'{-v,--verbose}'[verbose mode]' \
66- '(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]' \
67- '(-y --yes)'{-y,--yes}'[assume yes to all prompts]' \
68- + '(operation)' \
69- {-l,--list}'[list describable tasks]' \
70- {-a,--list-all}'[list all tasks]' \
71- {-i,--init}'[create new Taskfile.yml]' \
72- '(-*)'{-h,--help}'[show help]' \
73- '(-*)--version[show version and exit]' \
45+ local -a args
46+ args=(
47+ '(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: '
48+ '(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]'
49+ '(-f --force)'{-f,--force}'[run even if task is up-to-date]'
50+ '(-c --color)'{-c,--color}'[colored output]'
51+ '(--completion)--completion[generate shell completion script]:shell:(bash zsh fish powershell)'
52+ '(-d --dir)'{-d,--dir}'[dir to run in]:execution dir:_dirs'
53+ '(-n --dry)'{-n,--dry}'[compiles and prints tasks without executing]'
54+ '(--dry)--dry[dry-run mode, compile and print tasks only]'
55+ '(-x --exit-code)'{-x,--exit-code}'[pass-through exit code of task command]'
56+ '(--experiments)--experiments[list available experiments]'
57+ '(-g --global)'{-g,--global}'[run global Taskfile from home directory]'
58+ '(--insecure)--insecure[allow insecure Taskfile downloads]'
59+ '(-I --interval)'{-I,--interval}'[interval to watch for changes]:duration: '
60+ '(-j --json)'{-j,--json}'[format task list as JSON]'
61+ '(--nested)--nested[nest namespaces when listing as JSON]'
62+ '(--no-status)--no-status[ignore status when listing as JSON]'
63+ '(-o --output)'{-o,--output}'[set output style]:style:(interleaved group prefixed)'
64+ '(--output-group-begin)--output-group-begin[message template before grouped output]:template text: '
65+ '(--output-group-end)--output-group-end[message template after grouped output]:template text: '
66+ '(--output-group-error-only)--output-group-error-only[hide output from successful tasks]'
67+ '(-s --silent)'{-s,--silent}'[disable echoing]'
68+ '(--sort)--sort[set task sorting order]:order:(default alphanumeric none)'
69+ '(--status)--status[exit non-zero if supplied tasks not up-to-date]'
70+ '(--summary)--summary[show summary\: field from tasks instead of running them]'
71+ '(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files'
72+ '(-v --verbose)'{-v,--verbose}'[verbose mode]'
73+ '(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]'
74+ '(-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]'
7481 '*: :__task_list'
75- # Experimental flags (require experiments to be enabled)
76- # Uncomment when using GentleForce experiment:
77- # '(--force-all)--force-all[force execution of task and all dependencies]'
78- # Uncomment when using RemoteTaskfiles experiment:
79- # '(--download)--download[download remote Taskfile]'
80- # '(--offline)--offline[use only local or cached Taskfiles]'
81- # '(--timeout)--timeout[timeout for remote Taskfile downloads]:duration: '
82- # '(--clear-cache)--clear-cache[clear remote Taskfile cache]'
83- # '(--expiry)--expiry[cache expiry duration]:duration: '
82+ )
83+
84+ # Experimental flags (dynamically added based on enabled experiments)
85+ if __task_is_experiment_enabled "GENTLE_FORCE"; then
86+ args+=('(--force-all)--force-all[force execution of task and all dependencies]')
87+ fi
88+
89+ if __task_is_experiment_enabled "REMOTE_TASKFILES"; then
90+ args+=(
91+ '(--download)--download[download remote Taskfile]'
92+ '(--offline)--offline[use only local or cached Taskfiles]'
93+ '(--timeout)--timeout[timeout for remote Taskfile downloads]:duration: '
94+ '(--clear-cache)--clear-cache[clear remote Taskfile cache]'
95+ '(--expiry)--expiry[cache expiry duration]:duration: '
96+ )
97+ fi
98+
99+ _arguments $args
84100}
85101
86102# don't run the completion function when being source-ed or eval-ed
0 commit comments