_vagrant 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #compdef vagrant
  2. #autoload
  3. # vagrant zsh completion
  4. local -a _1st_arguments
  5. _1st_arguments=(
  6. 'box:Box commands'
  7. 'connect:Connects to a shared, remote Vagrant environment'
  8. 'destroy:Destroys the vagrant environment'
  9. 'docker-logs:Shows Docker logs'
  10. 'docker-run:Run one-off commands against a Docker container'
  11. 'global-status:Reports the status of all active Vagrant environments on the system'
  12. 'halt:Halts the currently running vagrant environment'
  13. 'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
  14. 'login:Authenticates against a Vagrant Cloud server to access protected boxes'
  15. 'package:Packages a vagrant environment for distribution'
  16. 'plugin:Plugin commands'
  17. 'provision:Run the provisioner'
  18. 'reload:Reload the vagrant environment'
  19. 'resume:Resumes a suspend vagrant environment'
  20. 'share:Shares the Vagrant environment and allows remote access'
  21. 'ssh:SSH into the currently running environment'
  22. 'ssh-config:outputs .ssh/config valid syntax for connecting to this environment via ssh'
  23. 'status:Shows the status of the current Vagrant environment'
  24. 'suspend:Suspends the currently running vagrant environment'
  25. 'up:Creates the vagrant environment'
  26. 'version:Prints the currently installed Vagrant version and checks for new updates'
  27. '--help:[TASK] Describe available tasks or one specific task'
  28. '--version:Prints the Vagrant version information'
  29. )
  30. local -a _box_arguments
  31. _box_arguments=(
  32. 'add:NAME URI Add a box to the system'
  33. 'help:COMMAND Describe subcommands or one specific subcommand'
  34. 'list:Lists all installed boxes'
  35. 'remove:NAME Remove a box from the system'
  36. 'repackage:NAME Repackage an installed box into a `.box` file.'
  37. )
  38. __task_list ()
  39. {
  40. local expl
  41. declare -a tasks
  42. tasks=(box destroy halt init package provision reload resume ssh ssh_config status suspend up version)
  43. _wanted tasks expl 'help' compadd $tasks
  44. }
  45. __box_list ()
  46. {
  47. _wanted application expl 'command' compadd $(command vagrant box list | sed -e 's/ /\\ /g')
  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. __vagrant-box ()
  54. {
  55. local curcontext="$curcontext" state line
  56. typeset -A opt_args
  57. _arguments -C \
  58. ':command:->command' \
  59. '*::options:->options'
  60. case $state in
  61. (command)
  62. _describe -t commands "gem subcommand" _box_arguments
  63. return
  64. ;;
  65. (options)
  66. case $line[1] in
  67. (repackage|remove)
  68. _arguments ':feature:__box_list'
  69. ;;
  70. esac
  71. ;;
  72. esac
  73. }
  74. local expl
  75. local -a boxes installed_boxes
  76. local curcontext="$curcontext" state line
  77. typeset -A opt_args
  78. _arguments -C \
  79. ':command:->command' \
  80. '*::options:->options'
  81. case $state in
  82. (command)
  83. _describe -t commands "gem subcommand" _1st_arguments
  84. return
  85. ;;
  86. (options)
  87. case $line[1] in
  88. (help)
  89. _arguments ':feature:__task_list'
  90. ;;
  91. (box)
  92. __vagrant-box
  93. ;;
  94. (up|provision|package|destroy|reload|ssh|halt|resume|status)
  95. _arguments ':feature:__vm_list'
  96. esac
  97. ;;
  98. esac