diff options
author | John Southworth <john.southworth@vyatta.com> | 2012-01-31 11:46:32 -0800 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2012-02-03 09:08:52 -0800 |
commit | e7b8873f980baf6d00d38b4b666082c9b6cc2309 (patch) | |
tree | 5904a39cf6816dc1ccdb364795b80267c17d9301 /etc | |
parent | 9a06bd552126d69db40d30779cfc49404e42d761 (diff) | |
download | vyatta-cfg-e7b8873f980baf6d00d38b4b666082c9b6cc2309.tar.gz vyatta-cfg-e7b8873f980baf6d00d38b4b666082c9b6cc2309.zip |
Fix some bugs in config path helpers
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/bash_completion.d/vyatta-cfg | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg index cbec48b..5e9592e 100755 --- a/etc/bash_completion.d/vyatta-cfg +++ b/etc/bash_completion.d/vyatta-cfg @@ -458,23 +458,31 @@ declare -a _get_help_text_helps=() get_help_text () { vyatta_help_text="\\nPossible completions:" + local print_node_type=$1 + local editlvl=$(cli-shell-api getEditLevelStr) for (( idx = 0; idx < ${#_get_help_text_items[@]}; idx++ )); do vyatta_help_text+="\\n" if (( ${#COMP_WORDS[@]} < 2 )) || [[ $COMP_CWORD -eq 0 ]]; then - vyatta_help_text+="\\x20\\x20\\x20" + vyatta_help_text+="\\x20\\x20" else - if [[ ${#_get_help_text_items[@]} == 1 ]]; then - local nodeType=$(cli-shell-api getNodeType ${api_args[@]:1:${comp_cword}}) + if [[ $print_node_type -ne 0 ]]; then + if [[ ${#_get_help_text_items[@]} == 1 ]]; then + local nodeType=$(cli-shell-api getNodeType ${editlvl} ${api_args[@]:1:${comp_cword}}) + #echo -e "\n $@ 1 $editlvl ${api_args[@]:1:$[${comp_cword}-1]} $nodeType\n" + else + local nodeType=$(cli-shell-api getNodeType ${editlvl} ${api_args[@]:1:$[${comp_cword}-1]} ${_get_help_text_items[idx]}) + #echo -e "\n $@ $editlvl ${api_args[@]:1:$[${comp_cword}-1]} ${_get_help_text_items[idx]} $nodeType\n" + fi + case "$nodeType" in + tag) vyatta_help_text+="+> " ;; + non-leaf) vyatta_help_text+=" > " ;; + multi) vyatta_help_text+="+ " ;; + *) vyatta_help_text+=" " ;; + esac else - local nodeType=$(cli-shell-api getNodeType ${api_args[@]:1:${comp_cword}} ${_get_help_text_items[idx]}) + vyatta_help_text+="\\x20\\x20" 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" @@ -701,7 +709,7 @@ generate_pipe_help () for comp in "${_get_help_text_items[@]}"; do _get_help_text_helps+=("$(_vyatta_pipe_help "$comp")") done - get_help_text + get_help_text 0 } ### Expand config compwords ### @@ -782,7 +790,7 @@ vyatta_config_invalid_comp () else echo -ne "\n\n Configuration path: $opath [$arg] is ambiguous\n" fi - get_help_text + get_help_text 0 echo -ne "$vyatta_help_text\n" | sed 's/^P/ P/' failed=true break @@ -856,7 +864,7 @@ vyatta_config_complete () _get_help_text_items=( "${fitems[@]}" ) _get_help_text_helps=( "${fstrs[@]}" ) fi - get_help_text + get_help_text 0 vyatta_completions=( "${_get_help_text_items[@]}" ) if [[ ${#vyatta_completions[@]} -eq 0 ]]; then echo -ne "\n\n Invalid command: [${COMP_WORDS[COMP_CWORD]}]" @@ -885,7 +893,7 @@ vyatta_config_complete () fi _get_help_text_items=("<Enter>" "discard") _get_help_text_helps=("Execute the current command" "Discard any changes") - get_help_text + get_help_text 0 vyatta_completions=("discard") vyatta_do_complete "$@" eval $restore_shopts @@ -909,7 +917,7 @@ vyatta_config_complete () # If parsing index 3, there's only one option. _get_help_text_items=("to") _get_help_text_helps=("Set destination") - get_help_text + get_help_text 1 vyatta_completions=("to") vyatta_do_complete "$@" eval $restore_shopts @@ -991,7 +999,7 @@ vyatta_config_complete () _get_help_text_items=( "${_cli_shell_api_hitems[@]}" ) vyatta_completions=( "${_cli_shell_api_comp_values[@]}" ) fi - get_help_text + get_help_text 1 vyatta_simple_complete "$@" eval $restore_shopts } |