kolla-ansible/contrib/bash-completion/kolla-ansible
jimmygc 94c5cc570a Add kolla-ansible bash completion script
Make command line more friendly. :)

Change-Id: I8113c72aa00b1c07cb2b77c73e7dd8c7ee833bcc
2017-05-12 09:06:36 +08:00

22 lines
668 B
Plaintext

_kolla_ansible() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
kolla_ansible_opts="$(kolla-ansible bash-completion)"
kolla_ansible_flags="$(echo ${kolla_ansible_opts} | sed 's/ [^-][a-z0-9_-]*//g' )"
kolla_ansible_actions="$(echo ${kolla_ansible_opts} | sed 's/--[a-z0-9-]*//g' | sed 's/ -[a-z]//g' )"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${kolla_ansible_flags}" -- ${cur}) )
return 0
else
COMPREPLY=( $(compgen -W "${kolla_ansible_actions}" -- ${cur}) )
return 0
fi
}
complete -F _kolla_ansible -A file kolla-ansible