Argument
No overview available.
def Argument(
default: Any | 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 | None = None,
default_factory: Callable[[], Any] | None = None,
parser: Callable[[str], Any] | None = None,
show_default: bool | str = True,
show_choices: bool = True,
show_envvar: bool = True,
help: str | None = None,
hidden: bool = False,
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
) - > Any
Defines a command-line argument for a Typer command, allowing for detailed configuration of validation, help text, and CLI behavior.
Parameters
| Name | Type | Description |
|---|---|---|
| default | `Any | None` = ... |
| callback | `Callable[..., Any] | None` = None |
| metavar | `str | None` = None |
| expose_value | bool = True | Determines whether the argument value should be passed to the command function or only used for side effects. |
| is_eager | bool = False | If true, processes this argument before others, often used for flags that exit early like --version. |
| envvar | `str | list[str] |
| shell_complete | `Callable | None` = None |
| autocompletion | `Callable | None` = None |
| default_factory | `Callable[[], Any] | None` = None |
| parser | `Callable[[str], Any] | None` = None |
| show_default | `bool | str` = True |
| show_choices | bool = True | If the argument has specific choices, determines if they are listed in the help text. |
| show_envvar | bool = True | Determines whether the associated environment variable name is displayed in the help text. |
| help | `str | None` = None |
| hidden | bool = False | If true, the argument exists but will not be listed in the help documentation. |
| case_sensitive | bool = True | Determines if string comparisons for choices should respect character casing. |
| min | `int | float |
| max | `int | float |
| clamp | bool = False | If true, values outside the min/max range are forced to the nearest boundary 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 | If true, file writes are performed to a temporary file and moved to the destination upon completion to prevent data loss. |
| exists | bool = False | If true, validates that the provided path already exists on the filesystem. |
| file_okay | bool = True | Determines if a file path is a valid input for this argument. |
| dir_okay | bool = True | Determines if a directory path is a valid input for this argument. |
| writable | bool = False | If true, validates that the user has write permissions for the provided path. |
| readable | bool = True | If true, validates that the user has read permissions for the provided path. |
| resolve_path | bool = False | If true, converts the provided path to an absolute path before passing it to the function. |
| allow_dash | bool = False | If true, allows a single dash '-' to represent stdin or stdout. |
| path_type | `None | type[str] |
| rich_help_panel | `str | None` = None |
Returns
| Type | Description |
|---|---|
Any | A TyperArgument instance used by the internal parser to define a positional command-line parameter. |