allow spec arguments to be "non-consuming" (doesn't show up in usage)
This commit is contained in:
parent
d7cc7781bd
commit
65b992e238
1 changed files with 14 additions and 5 deletions
|
@ -79,6 +79,7 @@ SPEC_ARGUMENT_TYPES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SpecArgument(object):
|
class SpecArgument(object):
|
||||||
|
consume = True
|
||||||
optional: bool = False
|
optional: bool = False
|
||||||
types: typing.List[SpecArgumentType] = []
|
types: typing.List[SpecArgumentType] = []
|
||||||
|
|
||||||
|
@ -155,8 +156,15 @@ def argument_spec(spec: str) -> typing.List[SpecArgument]:
|
||||||
out.append(SpecLiteralArgument.parse(optional,
|
out.append(SpecLiteralArgument.parse(optional,
|
||||||
spec_argument[2:].split(",")))
|
spec_argument[2:].split(",")))
|
||||||
else:
|
else:
|
||||||
out.append(SpecArgument.parse(optional,
|
consume = True
|
||||||
spec_argument[1:].split("|")))
|
if spec_argument[1] == "=":
|
||||||
|
consume = False
|
||||||
|
spec_argument = spec_argument[1:]
|
||||||
|
|
||||||
|
spec_argument_obj = SpecArgument.parse(optional,
|
||||||
|
spec_argument[1:].split("|"))
|
||||||
|
spec_argument_obj.consume = consume
|
||||||
|
out.append(spec_argument_obj)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
@ -164,6 +172,7 @@ def argument_spec_human(spec: typing.List[SpecArgument],
|
||||||
context: SpecArgumentContext=SpecArgumentContext.ALL) -> str:
|
context: SpecArgumentContext=SpecArgumentContext.ALL) -> str:
|
||||||
arguments: typing.List[str] = []
|
arguments: typing.List[str] = []
|
||||||
for spec_argument in spec:
|
for spec_argument in spec:
|
||||||
|
if spec_argument.consume:
|
||||||
out = spec_argument.format(context)
|
out = spec_argument.format(context)
|
||||||
if out:
|
if out:
|
||||||
arguments.append(out)
|
arguments.append(out)
|
||||||
|
|
Loading…
Reference in a new issue