f4pga/flows/common_modules/generic_script_wrapper: allow short flag names (#629)

This commit is contained in:
Unai Martinez-Corral 2022-08-29 18:50:55 +01:00 committed by GitHub
commit 7dcefb2757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
@ -238,6 +240,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):