Skip to content

context

CLASS DESCRIPTION
CliContext

Holds various state and I/O for commands.

CliContext(
    output_level: OutputLevel,
    log: Logger,
    console: ConsoleWrapper,
    fail_with_usage: Callable[[str], NoReturn],
    exit: Callable[[int], NoReturn],
    exception_handler: Callable[[CliContext, BaseException], None],
    app_dirs: AppDirs = app_dirs,
)

Holds various state and I/O for commands.

METHOD DESCRIPTION
fail

Aborts the execution of the program with a specific error message.

ATTRIBUTE DESCRIPTION
exception_handler

Handle exceptions with this context object.

TYPE: Callable[[CliContext, BaseException], None]

exit

Exits the application with a given exit code.

TYPE: Callable[[int], NoReturn]

fail_with_usage

Aborts the execution of the program with a specific error message and CLI help message.

TYPE: Callable[[str], NoReturn]

exception_handler: Callable[[CliContext, BaseException], None]

Handle exceptions with this context object.

exit: Callable[[int], NoReturn]

Exits the application with a given exit code.

fail_with_usage: Callable[[str], NoReturn]

Aborts the execution of the program with a specific error message and CLI help message.

fail(message: str) -> NoReturn

Aborts the execution of the program with a specific error message.

Source code in nava/platform/cli/context.py
28
29
30
31
def fail(self, message: str) -> NoReturn:
    """Aborts the execution of the program with a specific error message."""
    self.console.error.print(message)
    self.exit(1)