Skip to main content

OptionInfo

This class represents the metadata and configuration for a command-line option, extending the base parameter information. It manages a wide range of attributes including default values, environment variables, prompts, and validation constraints for various data types like files, paths, and numbers. Additionally, it supports integration with rich help panels and handles specific option behaviors such as counting and input hiding.

Attributes

AttributeTypeDescription
prompt`boolstr` = False
confirmation_promptbool = FalseEnables a second input prompt to confirm the value entered by the user.
prompt_requiredbool = TrueSpecifies if the user must provide a value during the interactive prompt.
hide_inputbool = FalseControls whether the user's input is masked or hidden in the terminal during the prompt.
countbool = FalseConfigures the option to increment an integer counter for every time it is repeated in the command line.
allow_from_autoenvbool = TrueDetermines if the option value can be automatically loaded from environment variables.

Constructor

Signature

def OptionInfo(
default: Any | None = None,
param_decls: Sequence[str]| None = None,
callback: Callable[..., Any]| None = None,
metavar: str | None = None,
expose_value: bool = True,
is_eager: bool = False,
envvar: str | list[str]| None = None,
shell_complete: Callable | None = None,
autocompletion: Callable[..., Any]| None = None,
default_factory: Callable[[], Any]| None = None,
parser: Callable[[str], Any]| None = None,
click_type: click.ParamType | None = None,
show_default: bool | str = True,
prompt: bool | str = False,
confirmation_prompt: bool = False,
prompt_required: bool = True,
hide_input: bool = False,
is_flag: bool | None = None,
flag_value: Any | None = None,
count: bool = False,
allow_from_autoenv: bool = True,
help: str | None = None,
hidden: bool = False,
show_choices: bool = True,
show_envvar: bool = True,
case_sensitive: bool = True,
min: int | float | None = None,
max: int | float | None = None,
clamp: bool = False,
formats: list[str]| None = None,
mode: str | None = None,
encoding: str | None = None,
errors: str | None = "strict",
lazy: bool | None = None,
atomic: bool = False,
exists: bool = False,
file_okay: bool = True,
dir_okay: bool = True,
writable: bool = False,
readable: bool = True,
resolve_path: bool = False,
allow_dash: bool = False,
path_type: None | type[str]| type[bytes] = None,
rich_help_panel: str | None = None
) - > null

Parameters

NameTypeDescription
default`AnyNone` = None
param_decls`Sequence[str]None` = None
callback`Callable[..., Any]None` = None
metavar`strNone` = None
expose_valuebool = TrueWhether the value should be passed to the command function.
is_eagerbool = FalseWhether the option should be processed before other parameters.
envvar`strlist[str]
shell_complete`CallableNone` = None
autocompletion`Callable[..., Any]None` = None
default_factory`Callable[[], Any]None` = None
parser`Callable[[str], Any]None` = None
click_type`click.ParamTypeNone` = None
show_default`boolstr` = True
prompt`boolstr` = False
confirmation_promptbool = FalseWhether to ask for confirmation when prompting.
prompt_requiredbool = TrueWhether the prompt is required.
hide_inputbool = FalseWhether to hide the input when prompting.
is_flag`boolNone` = None
flag_value`AnyNone` = None
countbool = FalseWhether to count the number of times the option is provided.
allow_from_autoenvbool = TrueWhether to allow the value to be read from auto-environment variables.
help`strNone` = None
hiddenbool = FalseWhether to hide the option from the help text.
show_choicesbool = TrueWhether to show the available choices in the help text.
show_envvarbool = TrueWhether to show the environment variable in the help text.
case_sensitivebool = TrueWhether choices are case-sensitive.
min`intfloat
max`intfloat
clampbool = FalseWhether to clamp numeric values to the min/max range.
formats`list[str]None` = None
mode`strNone` = None
encoding`strNone` = None
errors`strNone` = "strict"
lazy`boolNone` = None
atomicbool = FalseWhether file writes should be atomic.
existsbool = FalseWhether the path must exist.
file_okaybool = TrueWhether files are allowed for Path options.
dir_okaybool = TrueWhether directories are allowed for Path options.
writablebool = FalseWhether the path must be writable.
readablebool = TrueWhether the path must be readable.
resolve_pathbool = FalseWhether to resolve the path.
allow_dashbool = FalseWhether to allow a dash for stdin/stdout.
path_type`Nonetype[str]
rich_help_panel`strNone` = None

Signature

def OptionInfo(
default: Any | None = None,
param_decls: Sequence[str]| None = None,
callback: Callable[..., Any]| None = None,
metavar: str | None = None,
expose_value: bool = True,
is_eager: bool = False,
envvar: str | list[str]| None = None,
shell_complete: Callable | None = None,
autocompletion: Callable[..., Any]| None = None,
default_factory: Callable[[], Any]| None = None,
parser: Callable[[str], Any]| None = None,
click_type: click.ParamType | None = None,
show_default: bool | str = True,
prompt: bool | str = False,
confirmation_prompt: bool = False,
prompt_required: bool = True,
hide_input: bool = False,
is_flag: bool | None = None,
flag_value: Any | None = None,
count: bool = False,
allow_from_autoenv: bool = True,
help: str | None = None,
hidden: bool = False,
show_choices: bool = True,
show_envvar: bool = True,
case_sensitive: bool = True,
min: int | float | None = None,
max: int | float | None = None,
clamp: bool = False,
formats: list[str]| None = None,
mode: str | None = None,
encoding: str | None = None,
errors: str | None = "strict",
lazy: bool | None = None,
atomic: bool = False,
exists: bool = False,
file_okay: bool = True,
dir_okay: bool = True,
writable: bool = False,
readable: bool = True,
resolve_path: bool = False,
allow_dash: bool = False,
path_type: None | type[str]| type[bytes] = None,
rich_help_panel: str | None = None
) - > null

Parameters

NameTypeDescription
default`AnyNone` = None
param_decls`Sequence[str]None` = None
callback`Callable[..., Any]None` = None
metavar`strNone` = None
expose_valuebool = TrueWhether the value of this option should be passed to the command function.
is_eagerbool = FalseWhether this option should be processed before other parameters to trigger early actions like printing a version.
envvar`strlist[str]
shell_complete`CallableNone` = None
autocompletion`Callable[..., Any]None` = None
default_factory`Callable[[], Any]None` = None
parser`Callable[[str], Any]None` = None
click_type`click.ParamTypeNone` = None
show_default`boolstr` = True
prompt`boolstr` = False
confirmation_promptbool = FalseWhether to ask the user to input the value a second time for confirmation.
prompt_requiredbool = TrueWhether the prompt is mandatory even if the option is not required.
hide_inputbool = FalseWhether to mask the user's input, typically used for passwords or sensitive data.
is_flag`boolNone` = None
flag_value`AnyNone` = None
countbool = FalseWhether to increment an integer for every time the option is repeated (e.g., -vvv for verbosity level 3).
allow_from_autoenvbool = TrueWhether to allow reading the value from automatically generated environment variables.
help`strNone` = None
hiddenbool = FalseWhether to hide this option from the help documentation.
show_choicesbool = TrueWhether to show the valid choices for the option in the help text.
show_envvarbool = TrueWhether to show the associated environment variable in the help text.
case_sensitivebool = TrueWhether string comparisons for choices should respect character casing.
min`intfloat
max`intfloat
clampbool = FalseWhether to force the input value into the min/max range instead of raising an error.
formats`list[str]None` = None
mode`strNone` = None
encoding`strNone` = None
errors`strNone` = "strict"
lazy`boolNone` = None
atomicbool = FalseWhether file writes should be performed atomically using a temporary file.
existsbool = FalseWhether the provided path must already exist on the filesystem.
file_okaybool = TrueWhether a file is a valid path for this option.
dir_okaybool = TrueWhether a directory is a valid path for this option.
writablebool = FalseWhether the path must be writable by the current user.
readablebool = TrueWhether the path must be readable by the current user.
resolve_pathbool = FalseWhether to convert the input path to an absolute path.
allow_dashbool = FalseWhether to allow a single dash '-' to represent stdin or stdout.
path_type`Nonetype[str]
rich_help_panel`strNone` = None