Exceptions Module

Exceptions for Command Parser

author:

Doug Skrypa

exception cli_command_parser.exceptions.CommandParserException[source]

Bases: Exception

Base class for all other Command Parser exceptions

code: int = 3
show() bool[source]
exit()[source]
exception cli_command_parser.exceptions.ParserExit(message: str = None, code: int = 0)[source]

Bases: CommandParserException

Exception used to exit with the given message and status code

exception cli_command_parser.exceptions.CommandDefinitionError[source]

Bases: CommandParserException

An error caused by providing invalid options for a Command, or an invalid combination of Parameters

exception cli_command_parser.exceptions.ParameterDefinitionError[source]

Bases: CommandParserException

An error caused by providing invalid options for a Parameter

exception cli_command_parser.exceptions.AmbiguousShortForm(param_conflicts_map: Mapping[BaseOption, Collection[BaseOption]])[source]

Bases: ParameterDefinitionError

Raised when a Parameter’s short form contains multiple characters that would result in potentially ambiguous combinations with other Parameters’ short forms.

This will only be raised if config.ambiguous_short_combos is set to AmbiguousComboMode.STRICT

exception cli_command_parser.exceptions.AmbiguousParseTree(node: PosNode, target: Target, word: Word = None)[source]

Bases: CommandDefinitionError

Raised when a combination of parameters would result in ambiguous paths to take when parsing arguments

exception cli_command_parser.exceptions.UsageError[source]

Bases: CommandParserException

Base exception for user errors

message: str = None
exception cli_command_parser.exceptions.ParamUsageError(param: ParamOrGroup | None, message: str = None)[source]

Bases: UsageError

Error raised when a Parameter was not used correctly

exception cli_command_parser.exceptions.MultiParamUsageError(params: Collection[ParamOrGroup], message: str = None)[source]

Bases: UsageError

Error raised when a combination of Parameters was not used correctly

exception cli_command_parser.exceptions.AmbiguousCombo(params: Collection[ParamOrGroup], combo: str, message: str = None)[source]

Bases: MultiParamUsageError

Error raised when an ambiguous combination of short options were provided

exception cli_command_parser.exceptions.ParamConflict(params: Collection[ParamOrGroup], message: str = None)[source]

Bases: MultiParamUsageError

Error raised when mutually exclusive Parameters were combined

exception cli_command_parser.exceptions.ParamsMissing(params: Collection[ParamOrGroup], message: str = None, partial: bool = False)[source]

Bases: UsageError

Error raised when one or more required Parameters were not provided

exception cli_command_parser.exceptions.BadArgument(param: ParamOrGroup | None, message: str = None)[source]

Bases: ParamUsageError

Error raised when an invalid value is provided for a Parameter

exception cli_command_parser.exceptions.InvalidChoice(param: Parameter | None, invalid: Any, choices: Collection[Any], env_var: str = None)[source]

Bases: BadArgument

Error raised when a value that does not match one of the pre-defined choices was provided for a Parameter

exception cli_command_parser.exceptions.MissingArgument(param: ParamOrGroup | None, message: str = None)[source]

Bases: BadArgument

Error raised when a value for a Parameter was not provided

message: str = 'missing required argument value'
exception cli_command_parser.exceptions.TooManyArguments(param: ParamOrGroup, message: str = None)[source]

Bases: BadArgument

Error raised when too many values were provided for a Parameter

exception cli_command_parser.exceptions.NoSuchOption[source]

Bases: UsageError

Error raised when an option that was not defined as a Parameter was provided

exception cli_command_parser.exceptions.NoActiveContext[source]

Bases: CommandParserException, RuntimeError

Raised when attempting to perform an action that requires an active context while no context is active.

exception cli_command_parser.exceptions.Backtrack[source]

Bases: CommandParserException

Raised when backtracking took place. Only used internally.

exception cli_command_parser.exceptions.NextCommand[source]

Bases: CommandParserException

Raised by the parser to advance to the next Command in certain cases. Only used internally.