|
| 1 | +#compdef veewee |
| 2 | +# ------------------------------------------------------------------------------ |
| 3 | +# Description |
| 4 | +# ----------- |
| 5 | +# |
| 6 | +# Completion script for veewee 0.3.7 (https://github.com/jedi4ever/veewee) |
| 7 | +# |
| 8 | +# ------------------------------------------------------------------------------ |
| 9 | +# Authors |
| 10 | +# ------- |
| 11 | +# |
| 12 | +# * Marius Bergmann (https://github.com/mbrgm) |
| 13 | +# |
| 14 | +# ------------------------------------------------------------------------------ |
| 15 | + |
| 16 | +typeset curcontext state line cmds ret |
| 17 | + |
| 18 | +curcontext="$curcontext" |
| 19 | +ret=1 |
| 20 | + |
| 21 | +_arguments -C \ |
| 22 | + '--debug' \ |
| 23 | + '--workdir=[Change the working directory (the folder containing the definitions folder).]:directory:_files -/' \ |
| 24 | + '1: :->cmds' \ |
| 25 | + '2: :->providers' \ |
| 26 | + '*: :->args' && ret=0 |
| 27 | + |
| 28 | + |
| 29 | +local -a provider_cmds; provider_cmds=( |
| 30 | + 'build:Build box' |
| 31 | + 'copy:Copy a file to the VM' |
| 32 | + 'define:Define a new basebox starting from a template' |
| 33 | + 'destroy:Destroys the virtualmachine that was built' |
| 34 | + 'halt:Activates a shutdown the virtualmachine' |
| 35 | + 'help:Describe subcommands or one specific subcommand' |
| 36 | + 'list:Lists all defined boxes' |
| 37 | + 'ostypes:List the available Operating System types' |
| 38 | + 'sendkeys:Sends the key sequence (comma separated) to the box. E.g for testing the :boot_cmd_sequence' |
| 39 | + 'ssh:SSH to box' |
| 40 | + 'templates:List the currently available templates' |
| 41 | + 'undefine:Removes the definition of a basebox' |
| 42 | + 'up:Starts a Box' |
| 43 | + 'validate:Validates a box against vmfusion compliancy rules' |
| 44 | + 'winrm:Execute command via winrm' |
| 45 | +) |
| 46 | + |
| 47 | +case $state in |
| 48 | + cmds) |
| 49 | + local -a cmds; cmds=( |
| 50 | + 'fusion:Subcommand for Vmware fusion' |
| 51 | + 'help:Describe available commands or one specific command' |
| 52 | + 'kvm:Subcommand for KVM' |
| 53 | + 'parallels:Subcommand for Parallels' |
| 54 | + 'vbox:Subcommand for VirtualBox' |
| 55 | + 'version:Prints the Veewee version information' |
| 56 | + ) |
| 57 | + |
| 58 | + _describe -t commands 'veewee command' cmds && ret=0 |
| 59 | + ;; |
| 60 | + |
| 61 | + providers) |
| 62 | + case $line[1] in |
| 63 | + (help) |
| 64 | + local -a cmds; cmds=( |
| 65 | + 'fusion' |
| 66 | + 'help' |
| 67 | + 'kvm' |
| 68 | + 'parallels' |
| 69 | + 'vbox' |
| 70 | + 'version' |
| 71 | + ) |
| 72 | + |
| 73 | + _values -S , 'commands' $cmds && ret=0 |
| 74 | + ;; |
| 75 | + |
| 76 | + (fusion) |
| 77 | + provider_cmds+='add_share:Adds a share to the guest' |
| 78 | + provider_cmds+='export:Exports the basebox to the vagrant format' |
| 79 | + |
| 80 | + _describe -t commands 'veewee fusion command' provider_cmds && ret=0 |
| 81 | + ;; |
| 82 | + |
| 83 | + (kvm) |
| 84 | + provider_cmds+='export:Exports the basebox to the vagrant format' |
| 85 | + |
| 86 | + _describe -t commands 'veewee kvm command' provider_cmds && ret=0 |
| 87 | + ;; |
| 88 | + |
| 89 | + (parallels) |
| 90 | + _describe -t commands 'veewee parallels command' provider_cmds && ret=0 |
| 91 | + ;; |
| 92 | + |
| 93 | + (vbox) |
| 94 | + |
| 95 | + provider_cmds+='export:Exports the basebox to the vagrant format' |
| 96 | + provider_cmds+='screenshot:Takes a screenshot of the box' |
| 97 | + |
| 98 | + _describe -t commands 'veewee vbox command' provider_cmds && ret=0 |
| 99 | + ;; |
| 100 | + esac; |
| 101 | + ;; |
| 102 | + args) |
| 103 | + case $line[2] in |
| 104 | + (add_share|build|copy|destroy|export|halt|screenshot|sendkeys|ssh|undefine|up|validate|winrm) |
| 105 | + if [ ${#line[@]} -eq 3 ]; then |
| 106 | + boxes=( ${(f)"$(ls -1 ./definitions)"} ) |
| 107 | + _values -S , 'boxes' $boxes && ret=0 |
| 108 | + fi |
| 109 | + ;; |
| 110 | + (define) |
| 111 | + if [ ${#line[@]} -eq 4 ]; then |
| 112 | + templates=( ${(f)"$(_call_program templates veewee $line[1] templates | awk '/^veewee.+define/{sub(/^.+>[:\47] [:\47]/, "");sub(/[:\47].+$/, "");print}')"} ) |
| 113 | + _values -S , 'templates' $templates && ret=0 |
| 114 | + fi |
| 115 | + ;; |
| 116 | + (help) |
| 117 | + local -a cmds; cmds=( |
| 118 | + 'build' |
| 119 | + 'copy' |
| 120 | + 'define' |
| 121 | + 'destroy' |
| 122 | + 'halt' |
| 123 | + 'help' |
| 124 | + 'list' |
| 125 | + 'ostypes' |
| 126 | + 'sendkeys' |
| 127 | + 'ssh' |
| 128 | + 'templates' |
| 129 | + 'undefine' |
| 130 | + 'up' |
| 131 | + 'validate' |
| 132 | + 'winrm' |
| 133 | + ) |
| 134 | + if [ $line[1] = "fusion" ]; then |
| 135 | + cmds+='add_share' |
| 136 | + cmds+='export' |
| 137 | + elif [ $line[1] = "kvm" ]; then |
| 138 | + cmds+='export' |
| 139 | + elif [ $line[1] = "vbox" ]; then |
| 140 | + cmds+='export' |
| 141 | + cmds+='screenshot' |
| 142 | + fi |
| 143 | + _values -S , 'commands' $cmds && ret=0 |
| 144 | + ;; |
| 145 | + esac; |
| 146 | + case $line[2] in |
| 147 | + (add_share) |
| 148 | + if [ ${#line[@]} -eq 5 ]; then |
| 149 | + _arguments "*::filename:_files" |
| 150 | + fi |
| 151 | + ;; |
| 152 | + (copy) |
| 153 | + if [ ${#line[@]} -eq 4 ]; then |
| 154 | + _arguments "*::filename:_files" |
| 155 | + fi |
| 156 | + ;; |
| 157 | + (screenshot) |
| 158 | + if [ ${#line[@]} -eq 4 ]; then |
| 159 | + _arguments "*::filename:_files" |
| 160 | + fi |
| 161 | + ;; |
| 162 | + esac; |
| 163 | + ;; |
| 164 | +esac; |
0 commit comments