Skip to content

Instantly share code, notes, and snippets.

@igorepst
Created April 30, 2022 16:32
Show Gist options
  • Save igorepst/671eb238b25f212fe3f9a2e49bcc82a9 to your computer and use it in GitHub Desktop.
Save igorepst/671eb238b25f212fe3f9a2e49bcc82a9 to your computer and use it in GitHub Desktop.
foo_tools.sh compdef
#compdef foo-tools.sh
_foo_tools_sh() {
local -a commands
commands=(
"start:Start something"
"stop:Stop something"
"install:Install something"
"switch:Switch to something else"
"kube:kube commands"
"open-ports:Toggle ports"
)
_arguments -C \
'1:cmd:->cmds' \
'*:: :->args'
case "$state" in
cmds)
_describe -t commands 'commands' commands
;;
*)
case $words[1] in
kube)
local kube_cmds=(get edit)
_describe -t output 'Various kube commands' kube_cmds
;;
open-ports)
local ports_cmds=(on off)
_describe -t output 'Various ports commands' ports_cmds
;;
esac
;;
esac
}
_foo_tools_sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment