diff options
Diffstat (limited to 'etc/bash_completion.d/20vyatta-cfg')
-rwxr-xr-x | etc/bash_completion.d/20vyatta-cfg | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index d2d35ed..486c03b 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -376,6 +376,18 @@ vyatta_loadkey_complete() esac } +print_commit_log () +{ + local -a array + eval "array=($(${vyatta_sbindir}/vyatta-config-mgmt.pl --action=show-commit-log-brief))" + local count=0 + for i in "${array[@]}"; do + i=${i//_/ } + echo -e "$count\t$i" + (( count++ )) + done +} + vyatta_rollback_complete () { # Generate completion help for the "rollback" command @@ -388,14 +400,40 @@ vyatta_rollback_complete () if [ $COMP_CWORD -eq 1 -a -z "${COMP_WORDS[1]}" ]; then echo echo "Possible completions:" - local -a array - eval "array=($(${vyatta_sbindir}/vyatta-config-mgmt.pl --action=show-commit-log-brief))" - local count=0 - for i in "${array[@]}"; do - i=${i//_/ } - echo -e "$count\t$i" - (( count++ )) - done + echo -e "<N>\tRollback to revision N (currently requires reboot)" + print_commit_log + COMPREPLY=( "" " " ) + else + COMPREPLY=() + fi + + eval $restore_shopts +} + +vyatta_compare_complete () +{ + # Generate completion help for the "compare" command + + local restore_shopts=$( shopt -p extglob nullglob | tr \\n \; ) + shopt -s extglob nullglob + + # Only provide completions after command name has been typed, but + # before any characters of the command argument have been entered. + if [ $COMP_CWORD -eq 1 -a -z "${COMP_WORDS[1]}" ]; then + echo + echo "Possible completions:" + echo -e "<enter>\tCompare working & active configurations" + echo -e "<N>\tCompare working with revion N" + echo -e "<N> <M>\tCompare revion N with M" + print_commit_log + COMPREPLY=( "" " " ) + elif [ $COMP_CWORD -eq 2 -a -z "${COMP_WORDS[2]}" ]; then + echo + echo "Possible completions:" + echo -e "<enter>\tCompare working & active configurations" + echo -e "<N>\tCompare working with revion N" + echo -e "<N> <M>\tCompare revion N with M" + print_commit_log COMPREPLY=( "" " " ) else COMPREPLY=() @@ -814,7 +852,7 @@ complete -F vyatta_loadsave_complete save complete -F vyatta_loadsave_complete load complete -F vyatta_loadsave_complete merge complete -F vyatta_loadkey_complete loadkey -complete -F vyatta_config_complete compare +complete -F vyatta_compare_complete compare complete -F vyatta_config_complete comment complete -F vyatta_config_complete copy complete -F vyatta_config_complete rename |