Skip to content

yapx.cmd

Modify properties of a subcommand.

PARAMETER DESCRIPTION
function

the function called when this subcommand is provided.

TYPE: Union[None, Command, Callable[..., Any]] DEFAULT: None

name

the name of the subcommand added to the parser.

TYPE: Optional[str] DEFAULT: None

**kwargs

passed to the ArgumentParser constructor for this command.

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
Command

...

Examples:

>>> import yapx
...
>>> def sum_ints(*args: int):
...     print(sum(args))
...
>>> yapx.run_commands([
...     yapx.cmd(sum_ints, name="add-nums")
... ], args=["add-nums", "1", "2", "3"])
6