summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2012-01-28 12:25:52 -0800
committerJohn Southworth <john.southworth@vyatta.com>2012-02-03 09:08:44 -0800
commit9a06bd552126d69db40d30779cfc49404e42d761 (patch)
tree389bcb7f30dba43279e17666f0b1026670de285f /etc
parent2f0e1c14a1d956c8915a56e09610c1f6ab8ea40c (diff)
downloadvyatta-cfg-9a06bd552126d69db40d30779cfc49404e42d761.tar.gz
vyatta-cfg-9a06bd552126d69db40d30779cfc49404e42d761.zip
Add ability to differentiate between node types in help text
Diffstat (limited to 'etc')
-rwxr-xr-xetc/bash_completion.d/vyatta-cfg24
1 files changed, 20 insertions, 4 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg
index a32b8eb..cbec48b 100755
--- a/etc/bash_completion.d/vyatta-cfg
+++ b/etc/bash_completion.d/vyatta-cfg
@@ -459,13 +459,29 @@ get_help_text ()
{
vyatta_help_text="\\nPossible completions:"
for (( idx = 0; idx < ${#_get_help_text_items[@]}; idx++ )); do
- vyatta_help_text+="\\n\\x20\\x20"
- if [ ${#_get_help_text_items[idx]} -lt 6 ]; then
+ vyatta_help_text+="\\n"
+ if (( ${#COMP_WORDS[@]} < 2 )) ||
+ [[ $COMP_CWORD -eq 0 ]]; then
+ vyatta_help_text+="\\x20\\x20\\x20"
+ else
+ if [[ ${#_get_help_text_items[@]} == 1 ]]; then
+ local nodeType=$(cli-shell-api getNodeType ${api_args[@]:1:${comp_cword}})
+ else
+ local nodeType=$(cli-shell-api getNodeType ${api_args[@]:1:${comp_cword}} ${_get_help_text_items[idx]})
+ fi
+ case "$nodeType" in
+ tag) vyatta_help_text+="+> " ;;
+ non-leaf) vyatta_help_text+=" > " ;;
+ multi) vyatta_help_text+="+ " ;;
+ *) vyatta_help_text+=" " ;;
+ esac
+ fi
+ if [ ${#_get_help_text_items[idx]} -lt 5 ]; then
vyatta_help_text+="${_get_help_text_items[idx]}\\t\\t"
- elif [ ${#_get_help_text_items[idx]} -lt 14 ]; then
+ elif [ ${#_get_help_text_items[idx]} -lt 13 ]; then
vyatta_help_text+="${_get_help_text_items[idx]}\\t"
else
- vyatta_help_text+="${_get_help_text_items[idx]}\\n\\x20\\x20\\t\\t"
+ vyatta_help_text+="${_get_help_text_items[idx]}\\n\\x20\\x20\\x20\\t\\t"
fi
vyatta_help_text+="${_get_help_text_helps[idx]}"
done