tab completion for invoke.
This commit is contained in:
parent
01a921db85
commit
0e72d37a80
44
dotfiles/lib/completions/_invoke
Normal file
44
dotfiles/lib/completions/_invoke
Normal file
@ -0,0 +1,44 @@
|
||||
#compdef inv invoke
|
||||
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
_invoke_subcommand () {
|
||||
if [ -f tasks.py ]; then
|
||||
local cache_policy
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
||||
|
||||
if [[ -z "$cache_policy" ]]; then
|
||||
zstyle ":completion:${curcontext}:" cache-policy _invoke_subcommands_caching_policy
|
||||
fi
|
||||
|
||||
if ( [[ ${+_invoke_subcommands} -eq 0 ]] || _cache_invalid invoke_subcommands ) \
|
||||
&& ! _retrieve_cache invoke_subcommands; then
|
||||
|
||||
_invoke_subcommands=(${${(f)"$(inv -l | grep "^ [a-zA-Z]" | awk '{print $1}')"}})
|
||||
_store_cache invoke_subcommands _invoke_subcommands
|
||||
fi
|
||||
|
||||
local expl
|
||||
_wanted invoke_subcommands expl 'invoke subcommands' compadd -a _invoke_subcommands
|
||||
fi
|
||||
}
|
||||
|
||||
_invoke_subcommands_caching_policy() {
|
||||
local -a oldp
|
||||
oldp=( "$1"(Nmm+3) ) # 3min.
|
||||
(( $#oldp ))
|
||||
}
|
||||
|
||||
_arguments -s -S \
|
||||
"--no-dedupe[Disable task deduplication.]" \
|
||||
"(-c --collection)"{-c,--collection}"[Specify collection name to load. May be given >1 time.]" \
|
||||
"(-e --echo)"{-e,--echo}"[Echo executed commands before running.]" \
|
||||
"(-h --help)"{-h,--help}"[Show core or per-task help and exit.]:command:_invoke_subcommand" \
|
||||
"(-H --hide)"{-H,--hide}"[Set default value of run()'s 'hide' kwarg.]:command:_invoke_subcommand" \
|
||||
"(-l --list)"{-l,--list}"[List available tasks.]" \
|
||||
"(-p --pty)"{-p,--pty}"[Use a pty when executing shell commands.]" \
|
||||
"(-r --root)"{-r,--root}"[Change root directory used for finding task modules.]:directory:_directories" \
|
||||
"(-V --version)"{-V,--version}"[Show version and exit.]:" \
|
||||
"(-w --warn-only)"{-w,--warn-only}"[Warn, instead of failing, when shell commands fail.]" \
|
||||
"*::invoke commands:_invoke_subcommand"
|
Loading…
Reference in New Issue
Block a user