From 94c5cc570a845428d1a6ad7603e6b92b18b384b8 Mon Sep 17 00:00:00 2001 From: jimmygc Date: Mon, 8 May 2017 18:32:34 +0800 Subject: [PATCH] Add kolla-ansible bash completion script Make command line more friendly. :) Change-Id: I8113c72aa00b1c07cb2b77c73e7dd8c7ee833bcc --- contrib/bash-completion/kolla-ansible | 21 ++++++++++++ ...sh-completion-script-74d39268a829e1a2.yaml | 4 +++ tools/kolla-ansible | 32 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 contrib/bash-completion/kolla-ansible create mode 100644 releasenotes/notes/add-kolla-ansible-bash-completion-script-74d39268a829e1a2.yaml diff --git a/contrib/bash-completion/kolla-ansible b/contrib/bash-completion/kolla-ansible new file mode 100644 index 0000000000..56b8ea8ffc --- /dev/null +++ b/contrib/bash-completion/kolla-ansible @@ -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 diff --git a/releasenotes/notes/add-kolla-ansible-bash-completion-script-74d39268a829e1a2.yaml b/releasenotes/notes/add-kolla-ansible-bash-completion-script-74d39268a829e1a2.yaml new file mode 100644 index 0000000000..ea6d67a361 --- /dev/null +++ b/releasenotes/notes/add-kolla-ansible-bash-completion-script-74d39268a829e1a2.yaml @@ -0,0 +1,4 @@ +--- +features: + - Add kolla-ansible bash-completion script under + contrib/bash-completion folder. diff --git a/tools/kolla-ansible b/tools/kolla-ansible index 5af0df5d2f..7ecde31fc0 100755 --- a/tools/kolla-ansible +++ b/tools/kolla-ansible @@ -64,6 +64,34 @@ Commands: EOF } +function bash_completion { +cat <