summaryrefslogtreecommitdiff
path: root/python/vyos/opmode.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-04 15:24:59 +0200
committerGitHub <noreply@github.com>2023-05-04 15:24:59 +0200
commit3a35eca420c7b895323fdade0adf615c4a4eb675 (patch)
tree0755cde3bc48124917233ab4129bca2a14c3ecb7 /python/vyos/opmode.py
parent6e7dfd008ae8cd41abb6c12fa58c5dd8374ccba0 (diff)
parent6d4caef050a1aefbddbdae3ad3d3928e464426f1 (diff)
downloadvyos-1x-3a35eca420c7b895323fdade0adf615c4a4eb675.tar.gz
vyos-1x-3a35eca420c7b895323fdade0adf615c4a4eb675.zip
Merge pull request #1974 from dmbaturin/T5191-option-hyphens
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: