zsh-workers
 help / color / mirror / code / Atom feed
d22657310b90c2668d7f5a321f8549ad5d70777e blob 3143 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
 
#compdef vmctl

local -a subcommands alts

_vm_names() {
  local expl
  _description virtual-machines expl 'virtual machine'
  compadd "$@" "$expl[@]" - ${${${(@f)"$(_call_program virtual-machines vmctl status)"}[2,-1]}##* }
}

_vm_switches() {
  local expl
  _description virtual-switches expl 'virtual switch'
  [[ -r /etc/vm.conf ]] &&
  compadd "$@" "$expl[@]" - ${${${(M)${(f)"$(</etc/vm.conf)"}:#switch *}##switch ##\"#}%%\"# *}
}

subcommands=(
  console:'connect to the console of the VM'
  create:'create a VM disk image'
  load:'load additional configuration'
  log:'change logging verbosity'
  pause:'pause a VM'
  receive:'receive a VM from stdin'
  reload:'remove stopped VMs and reload config'
  reset:'reset specified component'
  send:'send VM to stdout and terminate it'
  {show,status}:'list VMs running or just the specified id'
  start:'start a VM'
  stop:'stop a VM'
  unpause:'resume a VM'
  wait:'wait until specified VM has stopped'
)

if (( CURRENT == 2 )); then
  _describe subcommand subcommands
else
  local curcontext="${curcontext%:*}-${words[2]}:"
  shift words; (( CURRENT-- ))
  case $words[1] in
    console|pause|send|show|status|unpause|wait)
      _vm_names
      ;;
    create)
      if (( CURRENT == 2 )); then
	compset -P '(raw|qcow2):' || alts=(
	  'prefixes:prefix:compadd -S: raw qcow2'
	)
	_alternative 'files:path:_files' $alts
      else
	shift words; (( CURRENT-- ))
	_arguments \
	  '-s+[specify size]:size' \
          '(-i)-b+[specify base disk]:base image:_files'
          '(-b)-i+[copy and convert input disk]:disk image:_files'
      fi
      ;;
    load)
      _arguments ':configuration file:_files'
      ;;
    log)
      _arguments ':logging verbosity:(brief verbose)'
      ;;
    receive)
      _arguments ':name: '
      ;;
    reset)
      _arguments ':reset option:((
        all\:"reset the running state"
        switches\:"reset the configured switches"
        vms\:"reset and terminate all VMs"
      ))'
      ;;
    start)
      if (( CURRENT == 2 )); then
        _vm_names
      else
        shift words; (( CURRENT-- ))
        _arguments -s \
          '-B+[force system to boot from specified device for this boot]:device:(cdrom disk net)' \
          '-b+[boot with the specified kernel or BIOS image]:boot image:_files' \
          '-c[automatically connect to the VM console]' \
          '*-d+[disk image file]:disk image:_files' \
          '-i+[number of network interfaces]:number: ' \
          '-L[add a local network interface]' \
          '-m+[specify memory size]:memory size (megabytes) [512]' \
          '-n+[specify switch to attach]: :_vm_switches' \
          '-r+[specify ISO image file for virtual CD-ROM]:ISO image:_files -g "*.iso(-.)"' \
	  '-t+[use existing VM as a template]: :_vm_names'
      fi
    ;;
    stop)
      if (( CURRENT == 2 )); then
	_alternative \
	  'all:all:(-a)' \
	  'virtual-machines: :_vm_names'
      else
	shift words; (( CURRENT-- ))
	_arguments \
	  '-f[forcefully stop without attempting a graceful shutdown]' \
	  '-w[wait until the VM has been terminated]'
      fi
    ;;
    *)
      _default
    ;;
  esac
fi
debug log:

solving d22657310 ...
found d22657310 in https://git.vuxu.org/mirror/zsh/

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).