From 044c4018d1e2fc57e8f82fe0c353ac7222d45bf8 Mon Sep 17 00:00:00 2001 From: Remi Paulmier Date: Thu, 11 Jun 2015 18:42:11 +0200 Subject: [PATCH] a first version a completion file for fleetctl --- src/_fleetctl | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/_fleetctl diff --git a/src/_fleetctl b/src/_fleetctl new file mode 100644 index 0000000..fd5f44e --- /dev/null +++ b/src/_fleetctl @@ -0,0 +1,102 @@ +#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