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#
| Type | Definition | Description |
|---|---|---|
ParseError | type ParseError = UnrecognizedOption | DuplicateOption | MissingOption | MissingArgument | UnexpectedArgument | InvalidValue | UnknownSubcommand | ValidationError | UserError | Every CLI error but |
Classes#
HasUserMessageCliErrorUnrecognizedOptionDuplicateOptionMissingOptionMissingArgumentUnexpectedArgumentInvalidValueUnknownSubcommandValidationErrorUserErrorShowHelp
Functions#
get_user_message#
get_user_message(error) -> str | NoneThe error's __cli_user_message__, if it has a string one.
| Parameter | Type | Description |
|---|---|---|
error | object |
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