#compdef fleetctl # ------------------------------------------------------------------------------ # Description # ----------- # # Completion script for fleetctl (https://github.com/coreos/fleet). # # # ------------------------------------------------------------------------------ # Authors # ------- # # * Remi Paulmier (https://github.com/shtouff) # # ------------------------------------------------------------------------------ # fleetctl zsh completion local -a _1st_arguments _1st_arguments=( 'cat:Output the contents of a submitted unit' 'destroy:Destroy one or more units in the cluster' 'fd-forward:Proxy stdin and stdout to a unix domain socket' 'help:Show a list of commands or help for one command' 'journal:Print the journal of a unit in the cluster to stdout' 'list-machines:Enumerate the current hosts in the cluster' 'list-unit-files:List the units that exist in the cluster.' 'list-units:List the current state of units in the cluster' 'load:Schedule one or more units in the cluster, first submitting them if necessary.' 'ssh:Open interactive shell on a machine in the cluster' 'start:Instruct systemd to start one or more units in the cluster, first submitting and loading if necessary.' 'status:Output the status of one or more units in the cluster' 'stop:Instruct systemd to stop one or more units in the cluster.' 'submit:Upload one or more units to the cluster without starting them' 'unload:Unschedule one or more units in the cluster.' 'version:Print the version and exit' ) __task_list () { local expl declare -a tasks tasks=(cat destroy fd-forward help journal list-machines list-unit-files \ list-units load ssh start status stop submit unload version) _wanted tasks expl 'help' compadd $tasks } __unit_list () { _wanted application expl 'command' compadd $(command fleetctl list-units | \ tail -n +2 | awk '{print $1}') } local expl local curcontext="$curcontext" state line local -A opt_args _arguments -C \ ':command:->command' \ '*::options:->options' case $state in (command) _describe -t commands "gem subcommand" _1st_arguments return ;; (options) case $line[1] in (help) _arguments ':feature:__task_list' ;; (destroy|journal|start|status|stop|unload|cat) _arguments '*:feature:__unit_list' ;; (load|submit) _arguments '*:file:_files -g *.service' ;; (ssh) _arguments '*:host:_hosts' ;; (*) _arguments '*:file:_files' ;; esac ;; esac # Local Variables: # mode: Shell-Script # sh-indentation: 2 # indent-tabs-mode: nil # sh-basic-offset: 2 # End: # vim: ft=zsh sw=2 ts=2 et