Blame view

repos/robbyrussell/oh-my-zsh/plugins/vagrant/_vagrant 3.91 KB
ed37aae5b   mj   Squashed 'repos/r...
1
  #compdef vagrant
093a6c34b   mj   Squashed 'repos/r...
2
3
4
5
6
7
8
  #autoload
  
  # vagrant zsh completion
  
  local -a _1st_arguments
  _1st_arguments=(
      'box:Box commands'
ed37aae5b   mj   Squashed 'repos/r...
9
      'connect:Connects to a remotely shared Vagrant environment'
093a6c34b   mj   Squashed 'repos/r...
10
      'destroy:Destroys the vagrant environment'
ed37aae5b   mj   Squashed 'repos/r...
11
12
      'docker-logs:Outputs the logs from the Docker container'
      'docker-run:Run a one-off command in the context of a container'
093a6c34b   mj   Squashed 'repos/r...
13
14
      'global-status:Reports the status of all active Vagrant environments on the system'
      'halt:Halts the currently running vagrant environment'
ed37aae5b   mj   Squashed 'repos/r...
15
      'help:Shows the help for a subcommand'
093a6c34b   mj   Squashed 'repos/r...
16
      'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
ed37aae5b   mj   Squashed 'repos/r...
17
      'list-commands:Outputs all available Vagrant subcommands, even non-primary ones'
093a6c34b   mj   Squashed 'repos/r...
18
19
20
21
      'login:Authenticates against a Vagrant Cloud server to access protected boxes'
      'package:Packages a vagrant environment for distribution'
      'plugin:Plugin commands'
      'provision:Run the provisioner'
ed37aae5b   mj   Squashed 'repos/r...
22
23
      'push:Deploys code in this environment to a configured destination'
      'rdp:Connects to machine via RDP'
093a6c34b   mj   Squashed 'repos/r...
24
25
      'reload:Reload the vagrant environment'
      'resume:Resumes a suspend vagrant environment'
ed37aae5b   mj   Squashed 'repos/r...
26
27
28
      'rsync:Syncs rsync synced folders to remote machine'
      'rsync-auto:Syncs rsync synced folders automatically when files change'
      'share:Shares your Vagrant environment with anyone in the world'
d9bebbb3c   mj   Squashed 'repos/r...
29
      'snapshot:Manage snapshots with the guest machine'
093a6c34b   mj   Squashed 'repos/r...
30
      'ssh:SSH into the currently running environment'
ed37aae5b   mj   Squashed 'repos/r...
31
      'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh'
093a6c34b   mj   Squashed 'repos/r...
32
33
      'status:Shows the status of the current Vagrant environment'
      'suspend:Suspends the currently running vagrant environment'
d9bebbb3c   mj   Squashed 'repos/r...
34
      'snapshot:Used to manage snapshots with the guest machine'
093a6c34b   mj   Squashed 'repos/r...
35
      'up:Creates the vagrant environment'
ed37aae5b   mj   Squashed 'repos/r...
36
      'version:Prints current and latest Vagrant version'
093a6c34b   mj   Squashed 'repos/r...
37
38
39
40
41
42
      '--help:[TASK] Describe available tasks or one specific task'
      '--version:Prints the Vagrant version information'
  )
  
  local -a _box_arguments
  _box_arguments=(
ed37aae5b   mj   Squashed 'repos/r...
43
44
      'add:ADDRESS Adds a box to the system'
      'help:COMMAND List subcommands'
093a6c34b   mj   Squashed 'repos/r...
45
      'list:Lists all installed boxes'
ed37aae5b   mj   Squashed 'repos/r...
46
47
48
49
      'outdated:Checks if a box has newer version'
      'remove:NAME Removes a box from the system'
      'repackage:NAME PROVIDER VERSION Repackages an installed box into a `.box` file'
      'update:Updates box to a newer version, if available'
093a6c34b   mj   Squashed 'repos/r...
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
  )
  
  __task_list ()
  {
      local expl
      declare -a tasks
  
      tasks=(box destroy halt init package provision reload resume ssh ssh_config status suspend up version)
  
      _wanted tasks expl 'help' compadd $tasks
  }
  
  __box_list ()
  {
      _wanted application expl 'command' compadd $(command vagrant box list | sed -e 's/ /\\ /g')
  }
  
  __vm_list ()
  {
      _wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
      _wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null)
  }
  
  __vagrant-box ()
  {
      local curcontext="$curcontext" state line
      typeset -A opt_args
  
      _arguments -C \
          ':command:->command' \
          '*::options:->options'
  
     case $state in
         (command)
             _describe -t commands "gem subcommand" _box_arguments
             return
         ;;
  
         (options)
             case $line[1] in
                 (repackage|remove)
ed37aae5b   mj   Squashed 'repos/r...
91
                     _arguments ':feature:__box_list'
093a6c34b   mj   Squashed 'repos/r...
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
                 ;;
             esac
         ;;
      esac
  }
  
  
  
  
  local expl
  local -a boxes installed_boxes
  
  local curcontext="$curcontext" state line
  typeset -A opt_args
  
  _arguments -C \
      ':command:->command' \
      '*::options:->options'
  
  case $state in
    (command)
        _describe -t commands "gem subcommand" _1st_arguments
        return
    ;;
  
    (options)
      case $line[1] in
        (help)
ed37aae5b   mj   Squashed 'repos/r...
120
           _arguments ':feature:__task_list'
093a6c34b   mj   Squashed 'repos/r...
121
122
123
124
125
        ;;
  
        (box)
            __vagrant-box
        ;;
56a5793ce   mj   Squashed 'repos/r...
126
        (up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status)
ed37aae5b   mj   Squashed 'repos/r...
127
        _arguments ':feature:__vm_list'
093a6c34b   mj   Squashed 'repos/r...
128
129
130
      esac
    ;;
  esac