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
| Attribute | Type | Description |
|---|---|---|
| prompt | `bool | str` = False |
| confirmation_prompt | bool = False | Enables a second input prompt to confirm the value entered by the user. |
| prompt_required | bool = True | Specifies if the user must provide a value during the interactive prompt. |
| hide_input | bool = False | Controls whether the user's input is masked or hidden in the terminal during the prompt. |
| count | bool = False | Configures the option to increment an integer counter for every time it is repeated in the command line. |
| allow_from_autoenv | bool = True | Determines 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
| Name | Type | Description |
|---|---|---|
| default | `Any | None` = None |
| param_decls | `Sequence[str] | None` = None |
| callback | `Callable[..., Any] | None` = None |
| metavar | `str | None` = None |
| expose_value | bool = True | Whether the value should be passed to the command function. |
| is_eager | bool = False | Whether the option should be processed before other parameters. |
| envvar | `str | list[str] |
| 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 | Whether to ask for confirmation when prompting. |
| prompt_required | bool = True | Whether the prompt is required. |
| hide_input | bool = False | Whether to hide the input when prompting. |
| is_flag | `bool | None` = None |
| flag_value | `Any | None` = None |
| count | bool = False | Whether to count the number of times the option is provided. |
| allow_from_autoenv | bool = True | Whether to allow the value to be read from auto-environment variables. |
| help | `str | None` = None |
| hidden | bool = False | Whether to hide the option from the help text. |
| show_choices | bool = True | Whether to show the available choices in the help text. |
| show_envvar | bool = True | Whether to show the environment variable in the help text. |
| case_sensitive | bool = True | Whether choices are case-sensitive. |
| min | `int | float |
| max | `int | float |
| clamp | bool = False | Whether to clamp numeric values to the min/max range. |
| formats | `list[str] | None` = None |
| mode | `str | None` = None |
| encoding | `str | None` = None |
| errors | `str | None` = "strict" |
| lazy | `bool | None` = None |
| atomic | bool = False | Whether file writes should be atomic. |
| exists | bool = False | Whether the path must exist. |
| file_okay | bool = True | Whether files are allowed for Path options. |
| dir_okay | bool = True | Whether directories are allowed for Path options. |
| writable | bool = False | Whether the path must be writable. |
| readable | bool = True | Whether the path must be readable. |
| resolve_path | bool = False | Whether to resolve the path. |
| allow_dash | bool = False | Whether to allow a dash for stdin/stdout. |
| path_type | `None | type[str] |
| rich_help_panel | `str | None` = 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
| Name | Type | Description |
|---|---|---|
| default | `Any | None` = None |
| param_decls | `Sequence[str] | None` = None |
| callback | `Callable[..., Any] | None` = None |
| metavar | `str | None` = None |
| expose_value | bool = True | Whether the value of this option should be passed to the command function. |
| is_eager | bool = False | Whether this option should be processed before other parameters to trigger early actions like printing a version. |
| envvar | `str | list[str] |
| 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 | Whether to ask the user to input the value a second time for confirmation. |
| prompt_required | bool = True | Whether the prompt is mandatory even if the option is not required. |
| hide_input | bool = False | Whether to mask the user's input, typically used for passwords or sensitive data. |
| is_flag | `bool | None` = None |
| flag_value | `Any | None` = None |
| count | bool = False | Whether to increment an integer for every time the option is repeated (e.g., -vvv for verbosity level 3). |
| allow_from_autoenv | bool = True | Whether to allow reading the value from automatically generated environment variables. |
| help | `str | None` = None |
| hidden | bool = False | Whether to hide this option from the help documentation. |
| show_choices | bool = True | Whether to show the valid choices for the option in the help text. |
| show_envvar | bool = True | Whether to show the associated environment variable in the help text. |
| case_sensitive | bool = True | Whether string comparisons for choices should respect character casing. |
| min | `int | float |
| max | `int | float |
| clamp | bool = False | Whether to force the input value into the min/max range instead of raising an error. |
| formats | `list[str] | None` = None |
| mode | `str | None` = None |
| encoding | `str | None` = None |
| errors | `str | None` = "strict" |
| lazy | `bool | None` = None |
| atomic | bool = False | Whether file writes should be performed atomically using a temporary file. |
| exists | bool = False | Whether the provided path must already exist on the filesystem. |
| file_okay | bool = True | Whether a file is a valid path for this option. |
| dir_okay | bool = True | Whether a directory is a valid path for this option. |
| writable | bool = False | Whether the path must be writable by the current user. |
| readable | bool = True | Whether the path must be readable by the current user. |
| resolve_path | bool = False | Whether to convert the input path to an absolute path. |
| allow_dash | bool = False | Whether to allow a single dash '-' to represent stdin or stdout. |
| path_type | `None | type[str] |
| rich_help_panel | `str | None` = None |