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 into command.

If unspecified, args will fall back to sys.argv.

parse_arg(command: Command, arg: str) Union[Tuple[Optional[Option], Optional[Any]], Command]

Parse arg using the scheme from command.

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 options

  • Short 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 in arg (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.