From 3a9d9b4297c56bae42b1fc10a08cfcce58496483 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 15 Jun 2022 06:38:09 -0400 Subject: T2719: correctly handle the raw argument for all show_* commands --- python/vyos/opmode.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'python/vyos') 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 -- cgit v1.2.3