diff options
author | John Estabrook <jestabro@vyos.io> | 2024-05-28 13:38:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 13:38:27 -0500 |
commit | ba5a1d34161812fd0e6bab3bc66f3003c66e5557 (patch) | |
tree | 2b4a16af2c8a84dea6c16a77bddb7ec2102cee2d | |
parent | 5915fa1b459a44d0b0928f4895ccde6ccb3e7af0 (diff) | |
parent | 6937d279dcdeadb21252c02d42f4f540c8af2e81 (diff) | |
download | vyatta-cfg-ba5a1d34161812fd0e6bab3bc66f3003c66e5557.tar.gz vyatta-cfg-ba5a1d34161812fd0e6bab3bc66f3003c66e5557.zip |
Merge pull request #81 from vyos/mergify/bp/sagitta/pr-79
cli: T6383: improve completion help for rollback commands (backport #79)
-rw-r--r-- | etc/bash_completion.d/vyatta-cfg | 35 | ||||
-rw-r--r-- | functions/interpreter/vyatta-cfg-run | 2 |
2 files changed, 35 insertions, 2 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg index c2d3a42..6274e1c 100644 --- a/etc/bash_completion.d/vyatta-cfg +++ b/etc/bash_completion.d/vyatta-cfg @@ -253,7 +253,40 @@ vyatta_rollback_complete () if [ $COMP_CWORD -eq 1 -a -z "${COMP_WORDS[1]}" ]; then echo echo "Possible completions:" - echo -e " <N>\tRollback to revision N (currently requires reboot)" + echo -e " <N>\tRollback to revision N (requires reboot)" + echo -e " \t(use rollback-soft for a non-disruptive rollback) + echo -e "\n Revisions:" + print_commit_log + COMPREPLY=( "" " " ) + else + echo -en "\nPossible completions:\n" + echo -en " <Enter>\tExecute the current command" + COMPREPLY=( "" " " ) + fi + + eval $restore_shopts +} + +vyatta_rollback-soft_complete () +{ + # Generate completion help for the "rollback-soft" command + + local restore_shopts=$( shopt -p extglob nullglob | tr \\n \; ) + shopt -s extglob nullglob + + if [[ $COMP_CWORD -eq 0 ]];then + vyatta_config_complete "$@" + eval $restore_shopts + return + fi + + # 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 " <N>\tRollback to revision N" + echo -e " \t(applies a diff that you can compare and commit)" echo -e "\n Revisions:" print_commit_log COMPREPLY=( "" " " ) diff --git a/functions/interpreter/vyatta-cfg-run b/functions/interpreter/vyatta-cfg-run index a13c62d..d1dbd51 100644 --- a/functions/interpreter/vyatta-cfg-run +++ b/functions/interpreter/vyatta-cfg-run @@ -627,7 +627,7 @@ _vyatta_cfg_init () rollback) complete -F vyatta_rollback_complete ${cmd:0:$pos} ;; rollback-soft) - complete -F vyatta_rollback_complete ${cmd:0:$pos} ;; + complete -F vyatta_rollback-soft_complete ${cmd:0:$pos} ;; commit|commit-confirm) complete -F vyatta_commit_complete ${cmd:0:$pos} ;; *) |