From 8b04f939d61be1bdc9279faf7bf66ec0ae6b6515 Mon Sep 17 00:00:00 2001 From: Krzysztof Boronski Date: Wed, 6 Jul 2022 10:52:31 -0500 Subject: [PATCH] generic script wrapper: allow short flag names Signed-off-by: Krzysztof Boronski --- f4pga/flows/common_modules/generic_script_wrapper.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/f4pga/flows/common_modules/generic_script_wrapper.py b/f4pga/flows/common_modules/generic_script_wrapper.py index ad860e8..932b4fa 100644 --- a/f4pga/flows/common_modules/generic_script_wrapper.py +++ b/f4pga/flows/common_modules/generic_script_wrapper.py @@ -75,6 +75,8 @@ def _parse_param_def(param_def: str): return "positional", int(param_def[1:]) elif param_def[0] == "$": return "environmental", param_def[1:] + elif param_def[0] == "-": + return "char", param_def[1:] return "named", param_def @@ -237,6 +239,16 @@ class GenericScriptWrapperModule(Module): named_args += [f"--{param}", str(val)] push = push_named + elif param_kind == "char": + + def push_char(val: "str | bool | int", param=param): + nonlocal named_args + if type(val) is bool: + named_args.append(f"-{param}") + else: + named_args += [f"-{param}", str(val)] + + push = push_char elif param_kind == "environmental": def push_environ(val: "str | bool | int", param=param):