diff options
author | Daniil Baturin <daniil@vyos.io> | 2022-07-05 06:47:48 -0400 |
---|---|---|
committer | Daniil Baturin <daniil@vyos.io> | 2022-07-05 06:47:48 -0400 |
commit | b8e2a0650168ce4958dc360f857c816f02c6284f (patch) | |
tree | 6842da0649121686702e360044f4453b34e809bb /python/vyos/opmode.py | |
parent | 81f7df57eeb0714bda8d9103659e644de48d1dc9 (diff) | |
download | vyos-1x-b8e2a0650168ce4958dc360f857c816f02c6284f.tar.gz vyos-1x-b8e2a0650168ce4958dc360f857c816f02c6284f.zip |
T2719: add general support for boolean options to generative op mode
Since Python as of 3.9 doesn't give us an option to look up
argument's default value by its name,
this implementation requires that all boolean options
must default to false.
Diffstat (limited to 'python/vyos/opmode.py')
-rw-r--r-- | python/vyos/opmode.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py index 134f55017..4e68d6e03 100644 --- a/python/vyos/opmode.py +++ b/python/vyos/opmode.py @@ -81,13 +81,10 @@ def run(module): for opt in type_hints: th = type_hints[opt] - # Show commands require an option to choose between raw JSON and human-readable - # formatted output. - # For interactive use, they default to formatted output. - if _is_show(function_name) and (opt == "raw"): - subparser.add_argument(f"--raw", action='store_true') - elif _is_optional_type(th): + if _is_optional_type(th): subparser.add_argument(f"--{opt}", type=_get_arg_type(th), default=None) + elif _get_arg_type(th) == bool: + subparser.add_argument(f"--{opt}", action='store_true') else: subparser.add_argument(f"--{opt}", type=_get_arg_type(th), required=True) |