_fab 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #compdef fab
  2. #autoload
  3. local curcontext=$curcontext state line
  4. declare -A opt_args
  5. declare target_list
  6. target_list=(`fab --shortlist 2>/dev/null`)
  7. _targets() {
  8. _describe -t commands "fabric targets" target_list
  9. }
  10. output_levels=(
  11. 'status: Status messages, i.e. noting when Fabric is done running, if the user used a keyboard interrupt, or when servers are disconnected from. These messages are almost always relevant and rarely verbose.'
  12. 'aborts: Abort messages. Like status messages, these should really only be turned off when using Fabric as a library, and possibly not even then. Note that even if this output group is turned off, aborts will still occur – there just won’t be any output about why Fabric aborted!'
  13. 'warnings: Warning messages. These are often turned off when one expects a given operation to fail, such as when using grep to test existence of text in a file. If paired with setting env.warn_only to True, this can result in fully silent warnings when remote programs fail. As with aborts, this setting does not control actual warning behavior, only whether warning messages are printed or hidden.'
  14. 'running: Printouts of commands being executed or files transferred, e.g. [myserver] run: ls /var/www. Also controls printing of tasks being run, e.g. [myserver] Executing task ''foo''.'
  15. 'stdout: Local, or remote, stdout, i.e. non-error output from commands.'
  16. 'stderr: Local, or remote, stderr, i.e. error-related output from commands.'
  17. 'user: User-generated output, i.e. local output printed by fabfile code via use of the fastprint or puts functions.'
  18. )
  19. _arguments -w -S -C \
  20. '(-)'{-h,--help}'[show this help message and exit]: :->noargs' \
  21. '(-)'{-V,--version}'[show program''s version number and exit]: :->noargs' \
  22. '(-)--list[print list of possible commands and exit]: :->noargs' \
  23. '(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
  24. '(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
  25. '(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
  26. "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \
  27. '(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
  28. '(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
  29. '(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
  30. '(-p+ --password=-)'{-p+,--password=-}'[password for use with authentication and/or sudo]: :' \
  31. '(-H+ --hosts=-)'{-H+,--hosts=-}'[comma separated list of hosts to operate on]: :' \
  32. '(-R+ --roles=-)'{-R+,--roles=-}'[comma separated list of roles to operate on]: :' \
  33. '(-a --no-agent)'{-a,--no-agent}'[don''t use the running SSH agent]' \
  34. '(-k --no-keys)'{-k,--no-keys}'[don''t load private key files from ~/.ssh/]' \
  35. '(-w --warn-only)'{-w,--warn-only}'[warn instead of abort, when commands fail]' \
  36. '-i+[path to SSH private key file. May be repeated]: :_files' \
  37. "(-f+ --fabfile=)"{-f+,--fabfile=}"[Python module file to import]: :_files -g *.py" \
  38. '(-c+ --config=-)'{-c+,--config=-}'[specify location of config file to use]: :_files' \
  39. '(-s+ --shell=-)'{-s+,--shell=-}'[specify a new shell, defaults to ''/bin/bash -l -c'']: :' \
  40. '(--hide=-)--hide=-[comma-separated list of output levels to hide]: :->levels' \
  41. '(--show=-)--show=-[comma-separated list of output levels to show]: :->levels' \
  42. '*::: :->subcmds' && return 0
  43. if [[ CURRENT -ge 1 ]]; then
  44. case $state in
  45. noargs)
  46. _message "nothing to complete";;
  47. levels)
  48. _describe -t commands "output levels" output_levels;;
  49. *)
  50. _targets;;
  51. esac
  52. return
  53. fi