summaryrefslogtreecommitdiff
path: root/python/vyos/opmode.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2023-04-28 17:57:29 +0100
committerDaniil Baturin <daniil@baturin.org>2023-05-04 01:45:53 +0100
commit6d4caef050a1aefbddbdae3ad3d3928e464426f1 (patch)
tree0755cde3bc48124917233ab4129bca2a14c3ecb7 /python/vyos/opmode.py
parent6e7dfd008ae8cd41abb6c12fa58c5dd8374ccba0 (diff)
downloadvyos-1x-6d4caef050a1aefbddbdae3ad3d3928e464426f1.tar.gz
vyos-1x-6d4caef050a1aefbddbdae3ad3d3928e464426f1.zip
opmode: T5191: replace underscores with hyphens in generated options
Diffstat (limited to 'python/vyos/opmode.py')
-rw-r--r--python/vyos/opmode.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py
index d7172a0b5..230a85541 100644
--- a/python/vyos/opmode.py
+++ b/python/vyos/opmode.py
@@ -209,6 +209,11 @@ def run(module):
for opt in type_hints:
th = type_hints[opt]
+ # Function argument names use underscores as separators
+ # but command-line options should use hyphens
+ # Without this, we'd get options like "--foo_bar"
+ opt = re.sub(r'_', '-', opt)
+
if _get_arg_type(th) == bool:
subparser.add_argument(f"--{opt}", action='store_true')
else: