patera.cli¶
CLI controllers. See the CLI guide.
Cli methods
CLIController
¶
Bases: Injectable, Generic[AppT]
Base class for CLI controllers.
Methods decorated with @command become commands, run as
patera cli <controller>:<command> [args...]. Arguments are read from
the method signature and converted to its annotated types.
commands
¶
commands() -> list[CLICommand]
Lists this controller's commands as controller:command names
with their arguments and help text, sorted by name.
usage
¶
Describes a command's arguments: <name:type> for required ones
and [name:type=default] for optional ones.
run_command
¶
Runs a CLI command. On failure the error is printed to stderr and the process exits with status code 1, so scripts/CI can detect failures.
convert_value
¶
Convert a CLI string value to the annotated type.
prepare_cli_args
¶
Convert raw CLI args to properly typed args based on method annotations. Missing optional arguments take their defaults. A missing required argument, or more arguments than the method accepts, raises ValueError.
CLICommand
¶
Bases: NamedTuple
One application command, as listed by patera cli.