]> git.rmz.io Git - dotfiles.git/blob - zsh/plugins/vagrant/_vagrant
9bed1e3c69d845c00100e21fdb2103a9d66dee4e
[dotfiles.git] / zsh / plugins / vagrant / _vagrant
1 #compdef vagrant
2 #autoload
3
4 # vagrant zsh completion
5
6 local -a _1st_arguments
7 _1st_arguments=(
8 'box:Box commands'
9 'destroy:Destroys the vagrant environment'
10 'halt:Halts the currently running vagrant environment'
11 'help:[TASK] Describe available tasks or one specific task'
12 'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
13 'package:Packages a vagrant environment for distribution'
14 'provision:Run the provisioner'
15 'reload:Reload the vagrant environment'
16 'resume:Resumes a suspend vagrant environment'
17 'ssh:SSH into the currently running environment'
18 'ssh_config:outputs .ssh/config valid syntax for connecting to this environment via ssh.'
19 'status:Shows the status of the current Vagrant environment.'
20 'suspend:Suspends the currently running vagrant environment'
21 'up:Creates the vagrant environment'
22 'version:Prints the Vagrant version information'
23 )
24
25 local -a _box_arguments
26 _box_arguments=(
27 'add:NAME URI Add a box to the system'
28 'help:COMMAND Describe subcommands or one specific subcommand'
29 'list:Lists all installed boxes'
30 'remove:NAME Remove a box from the system'
31 'repackage:NAME Repackage an installed box into a `.box` file.'
32 )
33
34 __task_list ()
35 {
36 local expl
37 declare -a tasks
38
39 tasks=(box destroy halt init package provision reload resume ssh ssh_config status suspend up version)
40
41 _wanted tasks expl 'help' compadd $tasks
42 }
43
44 __box_list ()
45 {
46 _wanted application expl 'command' compadd $(command ls -1 $HOME/.vagrant/boxes 2>/dev/null| sed -e 's/ /\\ /g')
47 }
48
49 __vm_list ()
50 {
51 _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *:\([a-zA-Z0-9]\+\)' 2>/dev/null | cut -d: -f2)
52 }
53
54 __vagrant-box ()
55 {
56 local curcontext="$curcontext" state line
57 typeset -A opt_args
58
59 _arguments -C \
60 ':command:->command' \
61 '*::options:->options'
62
63 case $state in
64 (command)
65 _describe -t commands "gem subcommand" _box_arguments
66 return
67 ;;
68
69 (options)
70 case $line[1] in
71 (repackage|remove)
72 _arguments ':feature:__box_list'
73 ;;
74 esac
75 ;;
76 esac
77 }
78
79
80
81
82 local expl
83 local -a boxes installed_boxes
84
85 local curcontext="$curcontext" state line
86 typeset -A opt_args
87
88 _arguments -C \
89 ':command:->command' \
90 '*::options:->options'
91
92 case $state in
93 (command)
94 _describe -t commands "gem subcommand" _1st_arguments
95 return
96 ;;
97
98 (options)
99 case $line[1] in
100 (help)
101 _arguments ':feature:__task_list'
102 ;;
103
104 (box)
105 __vagrant-box
106 ;;
107 (up|provision|package|destroy|reload|ssh|halt|resume|status)
108 _arguments ':feature:__vm_list'
109 esac
110 ;;
111 esac