diff options
author | Daniil Baturin <daniil@baturin.org> | 2019-10-27 15:38:25 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2019-10-27 16:02:04 +0100 |
commit | 209029dcf216a3e30cbdd394c205ac9908cce313 (patch) | |
tree | ccfa0eed2fddf6103d9d15b97382c946fb9301cd | |
parent | 2c8e8f701d488c404607afcb9273fec2edced9ba (diff) | |
download | vyatta-op-209029dcf216a3e30cbdd394c205ac9908cce313.tar.gz vyatta-op-209029dcf216a3e30cbdd394c205ac9908cce313.zip |
T1773: add a JSON pipe (show | json).
-rw-r--r-- | etc/bash_completion.d/vyatta-op | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/etc/bash_completion.d/vyatta-op b/etc/bash_completion.d/vyatta-op index 7ae4d61..ca0161f 100644 --- a/etc/bash_completion.d/vyatta-op +++ b/etc/bash_completion.d/vyatta-op @@ -510,6 +510,19 @@ commands () fi } +json () +{ + if [ "$_OFR_CONFIGURE" != "" ]; then + if $(cli-shell-api sessionChanged); then + echo "You have uncommited changes, please commit them before using the JSON pipe" + else + vyos-config-to-json + fi + else + echo "JSON pipe is not supported in operational mode" + fi +} + # pipe command help # $1: command _vyatta_pipe_help () @@ -523,6 +536,7 @@ _vyatta_pipe_help () no-more) help="Do not paginate the output";; strip-private) help="Remove private information from the config";; commands) help="Convert config to set commands";; + json) help="Convert config to JSON";; '<pattern>') help="Pattern for matching";; esac echo -n "$help" @@ -547,7 +561,7 @@ _vyatta_do_pipe_help () _vyatta_pipe_completion () { local -a pipe_cmd=() - local -a all_cmds=( 'count' 'match' 'no-match' 'more' 'no-more' 'strip-private' 'commands' ) + local -a all_cmds=( 'count' 'match' 'no-match' 'more' 'no-more' 'strip-private' 'commands' 'json' ) local found=0 _vyatta_pipe_completions=() _vyatta_pipe_noncompletions=() |