From 7ef742af1be72546d62f56583132bacd6f66094c Mon Sep 17 00:00:00 2001 From: Kun Huang Date: Fri, 13 Jun 2014 00:42:27 +0800 Subject: [PATCH] add bash completion script This patch add a script rally.bash_completion which enables auto-completion of rally CLI in bash environmnet when running: python setup.py install or python setup.py develop test: rally [tab] rally ta[tab] rally task [tab] rally task de[tab] to-do: adding a cache to bash-completion result could speed up auto-completion Change-Id: Ia4c68ccf3faea73da87a93ce64b36545d9d8411c --- setup.py | 1 + tools/rally.bash_completion | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tools/rally.bash_completion diff --git a/setup.py b/setup.py index 736375744d..18696b8de2 100644 --- a/setup.py +++ b/setup.py @@ -27,4 +27,5 @@ except ImportError: setuptools.setup( setup_requires=['pbr'], + data_files=[('/etc/bash_completion.d', ['tools/rally.bash_completion'])], pbr=True) diff --git a/tools/rally.bash_completion b/tools/rally.bash_completion new file mode 100644 index 0000000000..701e32d8e6 --- /dev/null +++ b/tools/rally.bash_completion @@ -0,0 +1,18 @@ +_rally_opts="" # lazy init +_rally_flags="" # lazy init +_rally_opts_exp="" # lazy init +_rally() +{ + local cur prev rbc cflags + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + base_opts="`rally bash-completion`" + if [ $prev == "rally" ] && [ $COMP_CWORD == "1" ] ; then + COMPREPLY=($(compgen -W "${base_opts}" -- ${cur})) + else + COMPREPLY=($(compgen -W "`rally bash-completion $prev `" -- ${cur})) + fi + return 0 +} +complete -F _rally rally