Base Module

Custom input handlers for Parameters

author:

Doug Skrypa

class cli_command_parser.inputs.base.InputType(fix_default: bool | Any = True)[source]

Bases: Generic[T], ABC

abstract __call__(value: str) T[source]

Process the parsed argument and convert it to the desired type

is_valid_type(value: str) bool[source]

Called during parsing when Parameter.would_accept() is called to determine if the value would be accepted later for processing / conversion via __call__(). May be overridden in subclasses to provide actual validation, if necessary.

Not called by Parameter.take_action() - value validation should happen in __call__()

Parameters:

value – A parsed argument

Returns:

True if this input would accept it for processing later (where it may still be rejected), False if it should be rejected before attempting to process / convert / store it.

fix_default(value: Any) T | None[source]
format_metavar(choice_delim: str = ',', sort_choices: bool = False) str[source]