App#

class cli_interview_kit.App[source]#

Bases: FrozenModel

A command-line app built from command declarations.

Attributes:
namestr

Program name.

descriptionstr

Top-level help.

versionstr

What --version prints after the name.

commandstuple[Command, …]

The top-level commands.

expected_errorstuple[type[Exception], …]

Further exception types whose message is reported like a CliError, for failures the app’s own libraries raise.

Methods

main([argv])

Run the command argv selects and return the exit code.

build_parser()

Return the argument parser for every declared command.

main(argv: Sequence[str] | None = None) → int[source]#

Run the command argv selects and return the exit code.

Parameters:
argvSequence[str] | None

The arguments after the program name; sys.argv[1:] if omitted.

Returns:
int

The exit code: 0 on success, 1 on a failure, 130 when interrupted.

Raises:
SystemExit

A usage error (an unknown flag, a bad choice) exits with status 2, as argparse does.

build_parser() → ArgumentParser[source]#

Return the argument parser for every declared command.

Returns:
ArgumentParser

The parser, with --version, --debug and one subparser per command.