Add kolla-ansible bash completion script

Make command line more friendly. :)

Change-Id: I8113c72aa00b1c07cb2b77c73e7dd8c7ee833bcc
This commit is contained in:
jimmygc 2017-05-08 18:32:34 +08:00
parent 97a5b1ecc3
commit 94c5cc570a
3 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,21 @@
_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

View File

@ -0,0 +1,4 @@
---
features:
- Add kolla-ansible bash-completion script under
contrib/bash-completion folder.

View File

@ -64,6 +64,34 @@ Commands:
EOF
}
function bash_completion {
cat <<EOF
--inventory -i
--playbook -p
--configdir
--key -k
--help -h
--tags -t
--extra -e
--passwords
--verbose -v
prechecks
check
mariadb_recovery
bootstrap-servers
destroy
deploy
deploy-bifrost
deploy-servers
post-deploy
pull
reconfigure
stop
certificates
upgrade
genconfig
EOF
}
SHORT_OPTS="hi:p:t:k:e:v"
LONG_OPTS="help,inventory:,playbook:,tags:,key:,extra:,verbose,configdir:,passwords:,yes-i-really-really-mean-it,include-images"
@ -233,6 +261,10 @@ EOF
ACTION="Generate configuration files for enabled OpenStack services"
EXTRA_OPTS="$EXTRA_OPTS -e action=config"
;;
(bash-completion)
bash_completion
exit 0
;;
(*) usage
exit 0
;;