My personal dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_fleetctl 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #compdef fleetctl
  2. # ------------------------------------------------------------------------------
  3. # Copyright (c) 2009-2015 Robby Russell and contributors (see
  4. # https://github.com/robbyrussell/oh-my-zsh/contributors)
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to deal
  8. # in the Software without restriction, including without limitation the rights
  9. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. # copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. # THE SOFTWARE.
  23. # ------------------------------------------------------------------------------
  24. # Description
  25. # -----------
  26. #
  27. # Completion script for fleetctl (https://github.com/coreos/fleet).
  28. #
  29. #
  30. # ------------------------------------------------------------------------------
  31. # Authors
  32. # -------
  33. #
  34. # * Remi Paulmier (https://github.com/shtouff)
  35. #
  36. # ------------------------------------------------------------------------------
  37. # fleetctl zsh completion
  38. local -a _1st_arguments
  39. _1st_arguments=(
  40. 'cat:Output the contents of a submitted unit'
  41. 'destroy:Destroy one or more units in the cluster'
  42. 'fd-forward:Proxy stdin and stdout to a unix domain socket'
  43. 'help:Show a list of commands or help for one command'
  44. 'journal:Print the journal of a unit in the cluster to stdout'
  45. 'list-machines:Enumerate the current hosts in the cluster'
  46. 'list-unit-files:List the units that exist in the cluster.'
  47. 'list-units:List the current state of units in the cluster'
  48. 'load:Schedule one or more units in the cluster, first submitting them if necessary.'
  49. 'ssh:Open interactive shell on a machine in the cluster'
  50. 'start:Instruct systemd to start one or more units in the cluster, first submitting and loading if necessary.'
  51. 'status:Output the status of one or more units in the cluster'
  52. 'stop:Instruct systemd to stop one or more units in the cluster.'
  53. 'submit:Upload one or more units to the cluster without starting them'
  54. 'unload:Unschedule one or more units in the cluster.'
  55. 'version:Print the version and exit'
  56. )
  57. __task_list ()
  58. {
  59. local expl
  60. declare -a tasks
  61. tasks=(cat destroy fd-forward help journal list-machines list-unit-files \
  62. list-units load ssh start status stop submit unload version)
  63. _wanted tasks expl 'help' compadd $tasks
  64. }
  65. __unit_list ()
  66. {
  67. _wanted application expl 'command' compadd $(command fleetctl list-units | \
  68. tail -n +2 | awk '{print $1}')
  69. }
  70. local expl
  71. local curcontext="$curcontext" state line
  72. local -A opt_args
  73. _arguments -C \
  74. ':command:->command' \
  75. '*::options:->options'
  76. case $state in
  77. (command)
  78. _describe -t commands "gem subcommand" _1st_arguments
  79. return
  80. ;;
  81. (options)
  82. case $line[1] in
  83. (help)
  84. _arguments ':feature:__task_list'
  85. ;;
  86. (destroy|journal|start|status|stop|unload|cat)
  87. _arguments '*:feature:__unit_list'
  88. ;;
  89. (load|submit)
  90. _arguments '*:file:_files -g *.service'
  91. ;;
  92. (ssh)
  93. _arguments '*:host:_hosts'
  94. ;;
  95. (*)
  96. _arguments '*:file:_files'
  97. ;;
  98. esac
  99. ;;
  100. esac
  101. # Local Variables:
  102. # mode: Shell-Script
  103. # sh-indentation: 2
  104. # indent-tabs-mode: nil
  105. # sh-basic-offset: 2
  106. # End:
  107. # vim: ft=zsh sw=2 ts=2 et