_vagrant 2.5 KB

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