_tugboat 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #compdef tugboat
  2. #autoload
  3. # Tugboat zsh autocompletion
  4. local -a _commands
  5. _commands=(
  6. 'add-key:[NAME] Upload an ssh public key.'
  7. 'authorize:Authorize a DigitalOcean account with tugboat.'
  8. 'create:[NAME] Create a droplet.'
  9. 'destroy:[FUZZY_NAME] Destroy a droplet.'
  10. 'destroy_image:[FUZZY_NAME] Destroy an image.'
  11. 'droplets:Retrieve a list of your droplets.'
  12. 'halt:[FUZZY_NAME] Shutdown a droplet.'
  13. 'help:[COMMAND] Describe commands or a specific command.'
  14. 'images:Retrieve a list of your images.'
  15. 'info:[FUZZY_NAME] [OPTIONS] Show a droplets information.'
  16. 'info_image:[FUZZY_NAME] [OPTIONS] Show an images information.'
  17. 'keys:Show available SSH keys.'
  18. 'password-reset:[FUZZY_NAME] Reset root password.'
  19. 'rebuild:[FUZZY_NAME] [IMAGE_NAME] Rebuild a droplet.'
  20. 'regions:Show regions.'
  21. 'resize:[FUZZY_NAME -s, --size=N] Resize a droplet.'
  22. 'restart:[FUZZY_NAME] Restart a droplet.'
  23. 'sizes:Show available droplet sizes.'
  24. 'snapshot:[SNAPSHOT_NAME] [FUZZY_NAME] [OPTIONS] Queue a snapshot of the droplet.'
  25. 'ssh:[FUZZY_NAME] SSH into a droplet.'
  26. 'start:[FUZZY_NAME] Start a droplet.'
  27. 'verify:Check your DigitalOcean credentials.'
  28. 'version:Show version.'
  29. 'wait:[FUZZY_NAME] Wait for a droplet to reach a state.'
  30. )
  31. local -a _create_arguments
  32. _create_arguments=(
  33. '-s:[--size=N] The size_id of the droplet'
  34. '-i:[--image=N] The image_id of the droplet'
  35. '-r:[--region=N] The region_id of the droplet'
  36. '-k:[--keys=KEYS] A comma separated list of SSH key ids to add to the droplet'
  37. '-p:[--private-networking] Enable private networking on the droplet'
  38. '-b:[--backups-enabled] Enable backups on the droplet'
  39. '-q:[--quiet]'
  40. )
  41. __task_list ()
  42. {
  43. local expl
  44. declare -a tasks
  45. arguments=(add-key authorize create destroy destroy_image droplets halt help images info info_image keys password-reset rebuild regions resize restart sizes snapshot ssh start verify version wait)
  46. _wanted tasks expl 'help' compadd $arguments
  47. }
  48. __droplets_list ()
  49. {
  50. _wanted application expl 'command' compadd $(command tugboat droplets | cut -d " " -f1)
  51. }
  52. __tugboat-create ()
  53. {
  54. local curcontext="$curcontext" state line
  55. typeset -A opt_args
  56. _arguments -C \
  57. ':command:->command' \
  58. '*::options:->options'
  59. case $state in
  60. (command)
  61. _describe -t commands "gem subcommand" _create_arguments
  62. return
  63. ;;
  64. esac
  65. }
  66. local curcontext="$curcontext" state line
  67. typeset -A opt_args
  68. _arguments -C \
  69. ':command:->command' \
  70. '*::options:->options'
  71. case $state in
  72. (command)
  73. _describe -t commands "gem subcommand" _commands
  74. return
  75. ;;
  76. (options)
  77. case $line[1] in
  78. (help)
  79. _arguments ':feature:__task_list'
  80. ;;
  81. (ssh)
  82. _arguments ':feature:__droplets_list'
  83. ;;
  84. (create)
  85. _arguments ':feature:__tugboat-create'
  86. ;;
  87. esac
  88. ;;
  89. esac