summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/opmode.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py
index 4e68d6e03..906bd0dcb 100644
--- a/python/vyos/opmode.py
+++ b/python/vyos/opmode.py
@@ -62,7 +62,7 @@ def _get_arg_type(t):
Doesn't work with anything else at the moment!
"""
if _is_optional_type(t):
- t.__args__[0]
+ return t.__args__[0]
else:
return t
@@ -81,12 +81,13 @@ def run(module):
for opt in type_hints:
th = type_hints[opt]
- if _is_optional_type(th):
- subparser.add_argument(f"--{opt}", type=_get_arg_type(th), default=None)
- elif _get_arg_type(th) == bool:
+ if _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)
+ if _is_optional_type(th):
+ subparser.add_argument(f"--{opt}", type=_get_arg_type(th), default=None)
+ else:
+ subparser.add_argument(f"--{opt}", type=_get_arg_type(th), required=True)
# Get options as a dict rather than a namespace,
# so that we can modify it and pack for passing to functions