diff options
author | Daniil Baturin <daniil@baturin.org> | 2019-10-27 15:38:25 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2021-01-24 18:26:19 +0100 |
commit | 48d73dabdb9e7986248a9fa54006ea192426b1ee (patch) | |
tree | fd987612ff16a09dcea3d7d0dfb71bdcd7a6d3fd /etc | |
parent | c5496c0c4209dc4e2376f377c57a9f2c4104fc95 (diff) | |
download | vyatta-op-48d73dabdb9e7986248a9fa54006ea192426b1ee.tar.gz vyatta-op-48d73dabdb9e7986248a9fa54006ea192426b1ee.zip |
T1773: add a JSON pipe (show | json).
Diffstat (limited to 'etc')
-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=() |