dryparse.parser
Functions for parsing the command line, i.e. converting command line arguments into their object representations.
- parse(command: Command, args: Optional[List[str]] = None)
Parse
args
intocommand
.If unspecified,
args
will fall back tosys.argv
.
- parse_arg(command: Command, arg: str) Union[Tuple[Optional[Option], Optional[Any]], Command]
Parse
arg
using the scheme fromcommand
.The argument can be an option (or option + value), a positional argument or a subcommand. For options, all the usual ways of specifying a CLI option are supported:
Long version:
--long
/--long=<value>
for bool/non-bool optionsShort version:
-s
/-s<value>
for bool/non-bool options
Returns
- (option, value)
Option object and its value, or
None
if the value was not specified inarg
(which means that the value must be found in the next argument on the command line, unless it’s a bool option).
Notes
This function does not take into consideration the case when the option name is specified as one argument and the option value as another argument.