mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 13:28:42 -05:00
Add tab completion script for zsh
This commit adds a new tab completion script for zsh. It also fixes the completion script for bash to work with ABS backends.
This commit is contained in:
parent
b31f44fb40
commit
57e7542f73
2 changed files with 38 additions and 1 deletions
|
|
@ -21,7 +21,7 @@ _vmfloaty()
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${_vmfloaty_avail_templates}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${_vmfloaty_avail_templates}" -- "${cur}") )
|
||||||
elif [[ $hostname_subcommands =~ (^| )$prev($| ) ]] ; then
|
elif [[ $hostname_subcommands =~ (^| )$prev($| ) ]] ; then
|
||||||
_vmfloaty_active_hostnames=$(floaty list --active 2>/dev/null | grep '^-' | cut -d' ' -f2)
|
_vmfloaty_active_hostnames=$(floaty list --active --hostnameonly 2>/dev/null)
|
||||||
COMPREPLY=( $(compgen -W "${_vmfloaty_active_hostnames}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${_vmfloaty_active_hostnames}" -- "${cur}") )
|
||||||
else
|
else
|
||||||
COMPREPLY=( $(compgen -W "${subcommands}" -- "${cur}") )
|
COMPREPLY=( $(compgen -W "${subcommands}" -- "${cur}") )
|
||||||
|
|
|
||||||
37
extras/completions/floaty.zsh
Normal file
37
extras/completions/floaty.zsh
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
_floaty()
|
||||||
|
{
|
||||||
|
local line subcommands template_subcommands hostname_subcommands
|
||||||
|
|
||||||
|
subcommands="delete get help list modify query revert snapshot ssh status summary token"
|
||||||
|
|
||||||
|
template_subcommands=("get" "ssh")
|
||||||
|
hostname_subcommands=("delete" "modify" "query" "revert" "snapshot")
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
"1: :(${subcommands})" \
|
||||||
|
"*::arg:->args"
|
||||||
|
|
||||||
|
if ((template_subcommands[(Ie)$line[1]])); then
|
||||||
|
_floaty_template_sub
|
||||||
|
elif ((hostname_subcommands[(Ie)$line[1]])); then
|
||||||
|
_floaty_hostname_sub
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_floaty_template_sub()
|
||||||
|
{
|
||||||
|
if [[ -z "$_vmfloaty_avail_templates" ]] ; then
|
||||||
|
_vmfloaty_avail_templates=$(floaty list 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
_arguments "1: :(${_vmfloaty_avail_templates})"
|
||||||
|
}
|
||||||
|
|
||||||
|
_floaty_hostname_sub()
|
||||||
|
{
|
||||||
|
_vmfloaty_active_hostnames=$(floaty list --active --hostnameonly 2>/dev/null)
|
||||||
|
|
||||||
|
_arguments "1: :(${_vmfloaty_active_hostnames})"
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _floaty floaty
|
||||||
Loading…
Add table
Add a link
Reference in a new issue