generic script wrapper: allow short flag names

Signed-off-by: Krzysztof Boronski <kboronski@antmicro.com>
This commit is contained in:
Krzysztof Boronski 2022-07-06 10:52:31 -05:00 committed by Unai Martinez-Corral
parent 831492aa0d
commit 8b04f939d6
1 changed files with 12 additions and 0 deletions

View File

@ -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):