1
0
mirror of https://github.com/go-task/task.git synced 2025-04-25 12:25:07 +02:00

Merge pull request #679 from philpennock/zsh-completion

completion: zsh: overhaul and sync to current flags
This commit is contained in:
Andrey Nering 2022-02-27 16:01:11 -03:00 committed by GitHub
commit c9aa0180a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,25 +1,60 @@
#compdef task #compdef task
# Listing commands from Taskfile.yml local context state state_descr line
function __list() { typeset -A opt_args
local -a scripts
if [ -f Taskfile.yml ] || [ -f Taskfile.yaml ]; then # Listing commands from Taskfile.yml
scripts=($(task -l | sed '1d' | sed 's/^\* //' | awk '{ print $1 }' | sed 's/:$//' | sed 's/:/\\:/g')) function __task_list() {
_describe 'script' scripts local -a scripts cmd
local -i enabled=0
local taskfile item task desc
cmd=(task)
taskfile="${(v)opt_args[(i)-t|--taskfile]}"
if [[ -n "$taskfile" && -f "$taskfile" ]]; then
enabled=1
cmd+=(--taskfile "$taskfile")
else
for taskfile in Taskfile{,.dist}.{yaml,yml}; do
if [[ -f "$taskfile" ]]; then
enabled=1
break
fi fi
done
fi
(( enabled )) || return 0
scripts=()
for item in "${(@)${(f)$("${cmd[@]}" --list)}[2,-1]#\* }"; do
task="${item%%:[[:space:]]*}"
desc="${item##[^[:space:]]##[[:space:]]##}"
scripts+=( "${task//:/\\:}:$desc" )
done
_describe 'Task to run' scripts
} }
_arguments \ _arguments \
'(-d --dir)'{-d,--dir}': :_files' \ '(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: ' \
'(--dry)'--dry \ '(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]' \
'(-f --force)'{-f,--force} \ '(-f --force)'{-f,--force}'[run even if task is up-to-date]' \
'(-i --init)'{-i,--init} \ '(-c --color)'{-c,--color}'[colored output]' \
'(-l --list)'{-l,--list} \ '(-d --dir)'{-d,--dir}'[dir to run in]:execution dir:_dirs' \
'(-s --silent)'{-s,--silent} \ '(--dry)--dry[dry-run mode, compile and print tasks only]' \
'(--status)'--status \ '(-o --output)'{-o,--output}'[set output style]:style:(interleaved group prefixed)' \
'(-v --verbose)'{-v,--verbose} \ '(--output-group-begin)--output-group-begin[message template before grouped output]:template text: ' \
'(--version)'--version \ '(--output-group-end)--output-group-end[message template after grouped output]:template text: ' \
'(-w --watch)'{-w,--watch} \ '(-s --silent)'{-s,--silent}'[disable echoing]' \
'(- *)'{-h,--help} \ '(--status)--status[exit non-zero if supplied tasks not up-to-date]' \
'*: :__list' \ '(--summary)--summary[show summary\: field from tasks instead of running them]' \
'(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files' \
'(-v --verbose)'{-v,--verbose}'[verbose mode]' \
'(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]' \
+ '(operation)' \
{-l,--list}'[list describable tasks]' \
{-a,--list-all}'[list all tasks]' \
{-i,--init}'[create new Taskfile.yaml]' \
'(-*)'{-h,--help}'[show help]' \
'(-*)--version[show version and exit]' \
'*: :__task_list'