GitHub

cli_error

API reference for cli_error.

The errors a command line can fail with (Effect's CliError).

Parsing collects UnrecognizedOption, MissingOption, InvalidValue and the rest; Command.run shows them with the help in a ShowHelp. A handler fails with UserError (or any error with a __cli_user_message__) to have the runner print a message for the user instead of a stack trace.

Types

TypeDefinitionDescription
ParseErrortype ParseError = UnrecognizedOption | DuplicateOption | MissingOption | MissingArgument | UnexpectedArgument | InvalidValue | UnknownSubcommand | ValidationError | UserError

Every CLI error but ShowHelp (Effect's NonShowHelpErrors).

Classes

Functions

get_user_message

get_user_message(error) -> str | None

The error's __cli_user_message__, if it has a string one.

ParameterTypeDescription
errorobject

Returns str | None

def get_user_message(error: object) -> str | None:
    """The error's ``__cli_user_message__``, if it has a string one."""
    message = getattr(error, "__cli_user_message__", None)
    return message if isinstance(message, str) else None