diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2010-11-11 16:17:19 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2010-11-11 16:17:19 -0800 |
commit | 1ccfc25ddd17e43e4283c84ab94d3a22a6f2c66a (patch) | |
tree | 11cab426d621005b180e92376af7835a8219d6b2 /etc/bash_completion.d | |
parent | cd9e0a08f49b43aa955849a3d9b9486ed3ae1d35 (diff) | |
download | vyatta-cfg-1ccfc25ddd17e43e4283c84ab94d3a22a6f2c66a.tar.gz vyatta-cfg-1ccfc25ddd17e43e4283c84ab94d3a22a6f2c66a.zip |
Add tab completion for "compare" command.
Diffstat (limited to 'etc/bash_completion.d')
-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 |