From 9a06bd552126d69db40d30779cfc49404e42d761 Mon Sep 17 00:00:00 2001 From: John Southworth Date: Sat, 28 Jan 2012 12:25:52 -0800 Subject: Add ability to differentiate between node types in help text --- etc/bash_completion.d/vyatta-cfg | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'etc/bash_completion.d') 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 -- cgit v1.2.3