From 6d4caef050a1aefbddbdae3ad3d3928e464426f1 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 28 Apr 2023 17:57:29 +0100 Subject: opmode: T5191: replace underscores with hyphens in generated options --- python/vyos/opmode.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'python') 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: -- cgit v1.2.3