Nargs Module
Helpers for handling nargs=...
for Parameters.
- author:
Doug Skrypa
- class cli_command_parser.nargs.Nargs(nargs: str | int | Tuple[int, int | None] | Sequence[int] | Set[int] | FrozenSet[int] | range | REMAINDER)[source]
Bases:
object
Helper class for validating the number of values provided for a given
Parameter
. Unifies the handling of different ways of specifying the required number of values.Acceptable values include
?
,*
, and+
, and they have the same meaning that they have in argparse. Additionally, integers, a range of integers, or a set/tuple of integers are accepted for more specific requirements.- allowed: Collection[int]
- satisfied(count: int) bool [source]
Returns True if the minimum number of values have been provided to satisfy the requirements, and if the number of values has not exceeded the maximum allowed. Returns False if the count is below the minimum or above the maximum.
For more advanced use cases, such as range or a set of counts, the count must also match one of the specific numbers provided for this to return True.