add utils.parse.argument_spec_human() for usage strings
This commit is contained in:
parent
bd33ea5d8a
commit
0c28d63822
1 changed files with 13 additions and 0 deletions
|
@ -232,3 +232,16 @@ def argument_spec(spec: str) -> typing.List[SpecArgument]:
|
|||
argument_type_name, exported))
|
||||
out.append(SpecArgument(optional, argument_types))
|
||||
return out
|
||||
|
||||
def argument_spec_human(spec: typing.List[SpecArgument]) -> str:
|
||||
out: typing.List[str] = []
|
||||
for spec_argument in spec:
|
||||
names = [t.name() or t.type for t in spec_argument.types]
|
||||
names = list(filter(None, names))
|
||||
|
||||
if spec_argument.optional:
|
||||
format = "[%s]"
|
||||
else:
|
||||
format = "<%s>"
|
||||
out.append(format % "|".join(names))
|
||||
return " ".join(out)
|
||||
|
|
Loading…
Reference in a new issue