zsh-workers
 help / color / mirror / code / Atom feed
98c6a95b3d4946544c75cd8a63b4ba8d33223ec0 blob 5272 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
 
#compdef virsh virt-admin virt-host-validate virt-pki-validate virt-xml-validate

local curcontext="$curcontext" state line expl ret=1

local exargs="-h --help -V -v --version=short --version=long"
local -a common_opts interact_cmds
common_opts=(
  '(- *)'{-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 $exargs)"{-c+,--connect=}'[specify connection URI]:URI:_hosts'
  "(-d --debug -q --quiet $exargs)"{-d+,--debug=}'[set debug level]:level:(0 1 2 3 4)'
  "(-l --log $exargs)"{-l+,--log=}'[specify log file]:file:_files'
  "(-q --quiet -d --debug $exargs)"{-q,--quiet}'[quiet mode]'
)
interact_cmds=(cd echo exit quit connect)

case $service in
  virsh)
    if (( ! $+_cache_virsh_cmds )); then
      _cache_virsh_cmds=( ${${${${(f):-"$(_call_program options virsh help)"}:#*:}/# ##}/ *} )
      local icmd
      for icmd in $interact_cmds; do
        _cache_virsh_cmds[$_cache_virsh_cmds[(i)$icmd]]=()
      done
    fi
    if (( ! $+_cache_virsh_cmdopts )); then
      typeset -gA _cache_virsh_cmdopts
    fi
    _arguments -A "-*" -C -S -s -w \
      "$common_opts[@]" \
      "(-e --escape $exargs)"{-e+,--escape=}'[set escape sequence for console]:sequence' \
      "(-k --keepalive-interval $exargs)"{-k+,--keepalive-interval=}'[set keepalive interval]:interval' \
      "(-K --keepalive-count $exargs)"{-K+,--keepalive-count=}'[set keepalive count]:count' \
      "(-r --readonly $exargs)"{-r,--readonly}'[connect readonly]' \
      "(-t --timing $exargs)"{-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
  ;;
  virt-admin)
    if (( ! $+_cache_virt_admin_cmds )); then
      _cache_virt_admin_cmds=( ${${${${(f):-"$(_call_program options virt-admin help)"}:#*:}/# ##}/ *} )
      local icmd
      for icmd in $interact_cmds; do
        _cache_virt_admin_cmds[$_cache_virt_admin_cmds[(i)$icmd]]=()
      done
    fi
    if (( ! $+_cache_virt_admin_cmdopts )); then
      typeset -gA _cache_virt_admin_cmdopts
    fi
    _arguments -A "-*" -C -S -s -w \
      "$common_opts[@]" \
      '1:command:->virt_admin_cmds' \
      '*:cmdopt:->virt_admin_cmdopts' && return
      # Same as with virsh above
      [[ -z $state ]] && state=virt_admin_cmdopts
  ;;
  virt-host-validate)
    _arguments -A "-*" -S \
      '(- *)'{-h,--help}'[print help information and exit]' \
      '(- *)'{-v,--version}'[print version information and exit]' \
      '(- *)'{-q,--quiet}'[quiet mode]' \
      '1:hv-type:(qemu lxc)' && return
  ;;
  virt-pki-validate)
    _arguments -A "-*" -S \
      '(- *)'{-h,--help}'[print help information and exit]' \
      '(- *)'{-V,--version}'[print version information and exit]' \
      && return
  ;;
  virt-xml-validate)
    _arguments -A "-*" -S \
      '(- *)'{-h,--help}'[print help information and exit]' \
      '(- *)'{-V,--version}'[print version information and exit]' \
      '1:file:_files -g "*.xml(-.)"' \
      '2:schema:(domainsnapshot domain network storagepool storagevol nodedev capability nwfilter secret interface)' \
      && return
  ;;
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 options virsh help $cmd 2>&1)"}}/\[}/\]}/\;}:#-[-0-9A-Za-z]*}
    fi
    _values -w options ${=_cache_virsh_cmdopts[$cmd]} && ret=0
  ;;
  virt_admin_cmds)
    _wanted commands expl 'virt-admin command' compadd -a _cache_virt_admin_cmds && ret=0
  ;;
  virt_admin_cmdopts)
    local cmd
    for (( i = 2; i <= $#words; i++ )); do
      [[ -n "${_cache_virt_admin_cmds[(r)$words[$i]]}" ]] && cmd=$words[$i] && break
    done
    [[ -z $cmd ]] && return 1
    if [[ $words[-2] == --server ]]; then
      _values servers ${=${(S)${${(f)$(_call_program -p servers virt-admin srv-list)}##*--- }//[0-9]* }} && return 0
    fi
    if [[ $words[-2] == --client ]]; then
      local srv
      for (( i = 2; i <= $#words; i++ )); do
        [[ $words[$i] == --server ]] && srv=$words[$i+1] && break
      done
      [[ -z $srv ]] && return 1
      _values servers ${=${${(f):-"$(_call_program -p servers virt-admin srv-clients-list --server $srv)"}/ [a-z]*}//[^0-9]} && return 0
    fi
    if [[ -z $_cache_virt_admin_cmdopts[$cmd] ]]; then
      _cache_virt_admin_cmdopts[$cmd]=${(M)${${${${=${(f)"$(_call_program options virt-admin help $cmd 2>&1)"}}/\[}/\]}/\;}:#-[-0-9A-Za-z]*}
    fi
    [[ -n $_cache_virt_admin_cmdopts[$cmd] ]] && \
      _values -w options ${=_cache_virt_admin_cmdopts[$cmd]} && ret=0
  ;;

esac

return ret
debug log:

solving 98c6a95 ...
found 98c6a95 in https://inbox.vuxu.org/zsh-workers/12554.1472678120@hydra.kiddle.eu/
found c855ac9 in https://git.vuxu.org/mirror/zsh/
preparing index
index prepared:
100644 c855ac980167db7686645bef2572cc8623577d9c	Completion/Unix/Command/_libvirt

applying [1/1] https://inbox.vuxu.org/zsh-workers/12554.1472678120@hydra.kiddle.eu/
diff --git a/Completion/Unix/Command/_libvirt b/Completion/Unix/Command/_libvirt
index c855ac9..98c6a95 100644

Checking patch Completion/Unix/Command/_libvirt...
Applied patch Completion/Unix/Command/_libvirt cleanly.

index at:
100644 98c6a95b3d4946544c75cd8a63b4ba8d33223ec0	Completion/Unix/Command/_libvirt

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).