mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-24 05:11:08 +02:00
38837 (tweaked c.f. 38826): new virsh completion
This commit is contained in:
parent
c32bb6a11c
commit
ccb45b3201
2 changed files with 58 additions and 0 deletions
|
@ -1,5 +1,8 @@
|
|||
2016-07-17 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* Marko Myllynen: 38837 (tweaked c.f. 38826):
|
||||
Completion/Unix/Command/_libvirt: new virsh completion
|
||||
|
||||
* 38845: Src/Zle/zle_main.c, Doc/Zsh/zle.yo: reset region_active
|
||||
before entering zle - it was on exit but before zle-line-finish
|
||||
Also reword documentation on region to better cover vi mode
|
||||
|
|
55
Completion/Unix/Command/_libvirt
Normal file
55
Completion/Unix/Command/_libvirt
Normal file
|
@ -0,0 +1,55 @@
|
|||
#compdef virsh
|
||||
|
||||
local curcontext="$curcontext" state line expl ret=1
|
||||
|
||||
case $service in
|
||||
virsh)
|
||||
if (( ! $+_cache_virsh_cmds )); then
|
||||
_cache_virsh_cmds=( ${${${${(f):-"$(_call_program options virsh help)"}:#*:}/# ##}/ *} )
|
||||
fi
|
||||
if (( ! $+_cache_virsh_cmdopts )); then
|
||||
typeset -gA _cache_virsh_cmdopts
|
||||
fi
|
||||
_arguments -A "-*" -C -S -s -w \
|
||||
'(- *)'{-h,--help}'[print help information and exit]' \
|
||||
'(- *)'{-v,--version=short}'[print short version information and exit]' \
|
||||
'(- *)'{-V,--version=long}'[print long version information and exit]' \
|
||||
'(-c --connect)'{-c+,--connect}'[specify connection URI]:URI:_hosts' \
|
||||
'(-d --debug)'{-d+,--debug}'[set debug level]:level:(0 1 2 3 4)' \
|
||||
'(-e --escape)'{-e+,--escape}'[set escape sequence for console]:sequence' \
|
||||
'(-k --keepalive-interval)'{-k+,--keepalive-interval}'[set keepalive interval]:interval' \
|
||||
'(-K --keepalive-count)'{-K+,--keepalive-count}'[set keepalive count]:count' \
|
||||
'(-l --log)'{-l+,--log}'[specify log file]:file:_files' \
|
||||
'(-q --quiet)'{-q,--quiet}'[quiet mode]' \
|
||||
'(-r --readonly)'{-r,--readonly}'[connect readonly]' \
|
||||
'(-t --timing)'{-t,--timing}'[print timing information]' \
|
||||
'1:command:->virsh_cmds' \
|
||||
'*:cmdopt:->virsh_cmdopts' && return
|
||||
# We accept only virsh command options after the first non-option argument
|
||||
# (i.e., the virsh command itself), this makes it so with the -A "-*" above
|
||||
[[ -z $state ]] && state=virsh_cmdopts
|
||||
;;
|
||||
esac
|
||||
|
||||
case $state in
|
||||
virsh_cmds)
|
||||
_wanted commands expl 'virsh command' compadd -a _cache_virsh_cmds && ret=0
|
||||
;;
|
||||
virsh_cmdopts)
|
||||
local cmd
|
||||
if [[ $words[-1] == /* || $words[-1] == ./* ]]; then
|
||||
_default
|
||||
return
|
||||
fi
|
||||
for (( i = 2; i <= $#words; i++ )); do
|
||||
[[ -n "${_cache_virsh_cmds[(r)$words[$i]]}" ]] && cmd=$words[$i] && break
|
||||
done
|
||||
[[ -z $cmd ]] && return 1
|
||||
if [[ -z $_cache_virsh_cmdopts[$cmd] ]]; then
|
||||
_cache_virsh_cmdopts[$cmd]=${(M)${${${${=${(f)"$(_call_program virsh virsh help $cmd 2>&1)"}}/\[}/\]}/\;}:#-[-0-9A-Za-z]*}
|
||||
fi
|
||||
_values -w options ${=_cache_virsh_cmdopts[$cmd]} && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
Loading…
Reference in a new issue