aboutsummaryrefslogtreecommitdiffstats
path: root/src/_supervisorctl
diff options
context:
space:
mode:
authormafro <github@mafro.net>2015-02-12 11:44:11 +1100
committerMatt Black <github@mafro.net>2015-10-16 06:57:00 +0100
commitb0b0f1c85bd1c7a0224ade87b50813562273884c (patch)
tree0764de062c7278311a6ce45681751590ee6e2356 /src/_supervisorctl
parentMerge pull request #345 from termoshtt/stack (diff)
downloadzsh-completions-b0b0f1c85bd1c7a0224ade87b50813562273884c.tar
zsh-completions-b0b0f1c85bd1c7a0224ade87b50813562273884c.tar.gz
zsh-completions-b0b0f1c85bd1c7a0224ade87b50813562273884c.tar.bz2
zsh-completions-b0b0f1c85bd1c7a0224ade87b50813562273884c.tar.lz
zsh-completions-b0b0f1c85bd1c7a0224ade87b50813562273884c.tar.xz
zsh-completions-b0b0f1c85bd1c7a0224ade87b50813562273884c.tar.zst
zsh-completions-b0b0f1c85bd1c7a0224ade87b50813562273884c.zip
add supervisorctl completion
Diffstat (limited to 'src/_supervisorctl')
-rw-r--r--src/_supervisorctl149
1 files changed, 149 insertions, 0 deletions
diff --git a/src/_supervisorctl b/src/_supervisorctl
new file mode 100644
index 0000000..07ce2ed
--- /dev/null
+++ b/src/_supervisorctl
@@ -0,0 +1,149 @@
+#compdef supervisorctl
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# Completion script for supervisorctl from Supervisord (http://supervisord.org)
+#
+# Sources:
+# https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/supervisor
+# https://github.com/zsh-users/zsh-completions/blob/master/src/_brew
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * Matt Black (https://github.com/mafrosis)
+# * dongweiming (https://github.com/dongweiming)
+#
+# ------------------------------------------------------------------------------
+
+
+_supervisorctl_list_procs() {
+ procs=(${(f)"$(_call_program supervisor_procs supervisorctl avail | awk '{print $1}')"})
+}
+_supervisorctl_list_groups() {
+ groups=(${(f)"$(_call_program supervisor_procs supervisorctl avail | awk '$1 ~ /:/ { print substr($1,1,index($1,":")) }' | uniq)"})
+}
+
+_supervisorctl_list_procs_stopped() {
+ procs=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '/STOPPED/ {print $1}')"})
+}
+_supervisorctl_list_groups_stopped() {
+ groups=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '$1$2 ~ /:(.*)STOPPED/ { print substr($1,1,index($1,":")) }' | uniq)"})
+}
+
+_supervisorctl_list_procs_running() {
+ procs=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '/RUNNING/ {print $1}')"})
+}
+_supervisorctl_list_groups_running() {
+ groups=(${(f)"$(_call_program supervisor_procs supervisorctl status | awk '$1$2 ~ /:(.*)RUNNING/ { print substr($1,1,index($1,":")) }' | uniq)"})
+}
+
+local -a _1st_arguments
+_1st_arguments=(
+ 'add:Activates any updates in config for process/group'
+ 'avail:Display all configured processes'
+ 'clear:Clear single/multiple/all process log files'
+ 'exit:Exit the supervisor shell'
+ 'fg:Connect to a process in foreground mode'
+ 'maintail:tail of supervisor main log file'
+ 'open:Connect to a remote supervisord process. (for UNIX domain socket, use unix:///socket/path)'
+ 'pid:Get the PID of process/supervisord'
+ 'quit:Exit the supervisor shell'
+ 'reload:Restart the remote supervisord'
+ 'remove:Removes process/group from active config'
+ "reread:Reload the daemon's configuration files"
+ 'restart:Restart process, group or all'
+ 'shutdown:Shut the remote supervisord down'
+ 'start:Start process, group or all'
+ 'status:Get process/group status info'
+ 'stop:Stop process, group or all'
+ 'tail:tail of process stdout'
+ 'update:Reload config and add/remove as necessary'
+ 'version:Show the version of the remote supervisord process'
+ 'help:Show help'
+)
+
+local expl
+local -a procs
+
+_arguments \
+ {--configuration,-c}='[configuration file path (default /etc/supervisor.conf)]:filename:_files' \
+ {--help,-h}'[print usage message and exit]:' \
+ {--interactive,-i}'[start an interactive shell after executing commands]' \
+ {--serverurl,-s}='[URL on which supervisord server is listening (default "http://localhost:9001")]' \
+ {--username,-u}='[username to use for authentication with server]:username:_users' \
+ {--password,-p}='[password to use for authentication with server]:password:' \
+ {--history-file,-r}'[keep a readline history (if readline is available)]:filename:_files' \
+ '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands 'supervisorctl subcommand' _1st_arguments
+ return
+fi
+
+case "$words[1]" in
+ help)
+ tasks=(add avail clear exit fg maintail open pid quit reload remove \
+ reread restart shutdown start status stop tail update version)
+
+ _wanted tasks expl 'help' compadd $tasks ;;
+
+ add|fg|remove)
+ # commands that only operate on processes
+ _supervisorctl_list_procs
+ _wanted procs expl 'process' compadd -a procs ;;
+
+ clear|pid)
+ # commands that operate on processes and "all"
+ _supervisorctl_list_procs
+ procs+=('all')
+ _wanted procs expl 'process' compadd -a procs ;;
+
+ status|update)
+ # commands that operate on processes, groups & "all"
+ _supervisorctl_list_procs
+ procs+=('all')
+ _wanted procs expl 'process' compadd -a procs
+
+ _supervisorctl_list_groups
+ _wanted groups expl 'group' compadd -a groups ;;
+
+ stop)
+ # commands that operate on RUNNING processes, groups & "all"
+ _supervisorctl_list_procs_running
+ procs+=('all')
+ _wanted procs expl 'process' compadd -a procs
+
+ _supervisorctl_list_groups_running
+ _wanted groups expl 'group' compadd -a groups ;;
+
+ restart|start)
+ # commands that operate on STOPPED processes, groups & "all"
+ _supervisorctl_list_procs_stopped
+ procs+=('all')
+ _wanted procs expl 'process' compadd -a procs
+
+ _supervisorctl_list_groups_stopped
+ _wanted groups expl 'group' compadd -a groups ;;
+
+ tail|maintail)
+ _arguments \
+ '-f[Continuous tail of named process stdout]' \
+ '-[last N *bytes* of process stdout]:number' \
+ '1: :->forms' && return 0
+
+ if [[ $state == forms ]]; then
+ _supervisorctl_list_procs
+ _wanted procs expl 'processes' compadd -a procs
+ fi ;;
+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