diff options
author | Daniil Baturin <daniil@vyos.io> | 2022-06-15 06:38:09 -0400 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2022-06-15 06:38:09 -0400 |
commit | 3a9d9b4297c56bae42b1fc10a08cfcce58496483 (patch) | |
tree | ef640b98c62fb814451c129d83a9207afcfcae7a /python/vyos/opmode.py | |
parent | f08b850f297422925b8e0a16d67accee6843b9e1 (diff) | |
download | vyos-1x-3a9d9b4297c56bae42b1fc10a08cfcce58496483.tar.gz vyos-1x-3a9d9b4297c56bae42b1fc10a08cfcce58496483.zip |
T2719: correctly handle the raw argument for all show_* commands
Diffstat (limited to 'python/vyos/opmode.py')
-rw-r--r-- | python/vyos/opmode.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py index 692e5fc98..10e8770d3 100644 --- a/python/vyos/opmode.py +++ b/python/vyos/opmode.py @@ -103,16 +103,20 @@ def run(module): parser.print_usage() sys.exit(1) - func = functions[args["subcommand"]] + function_name = args["subcommand"] + func = functions[function_name] # Remove the subcommand from the arguments, # it would cause an extra argument error when we pass the dict to a function del args["subcommand"] - if "raw" not in args: + # Show commands must always get the "raw" argument, + # but other commands (clear/reset/restart) should not, + # because they produce no output and it makes no sense for them. + if ("raw" not in args) and re.match(r"^show", function_name): args["raw"] = False - if function_name == "show": + if re.match(r"^show", function_name): # Show commands are slightly special: # they may return human-formatted output # or a raw dict that we need to serialize in JSON for printing |