Skip to main content

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

NameTypeDescription
default`AnyNone` = ...
callback`Callable[..., Any]None` = None
metavar`strNone` = None
expose_valuebool = TrueDetermines whether the argument value should be passed to the command function or only used for side effects.
is_eagerbool = FalseIf true, processes this argument before others, often used for flags that exit early like --version.
envvar`strlist[str]
shell_complete`CallableNone` = None
autocompletion`CallableNone` = None
default_factory`Callable[[], Any]None` = None
parser`Callable[[str], Any]None` = None
show_default`boolstr` = True
show_choicesbool = TrueIf the argument has specific choices, determines if they are listed in the help text.
show_envvarbool = TrueDetermines whether the associated environment variable name is displayed in the help text.
help`strNone` = None
hiddenbool = FalseIf true, the argument exists but will not be listed in the help documentation.
case_sensitivebool = TrueDetermines if string comparisons for choices should respect character casing.
min`intfloat
max`intfloat
clampbool = FalseIf true, values outside the min/max range are forced to the nearest boundary instead of raising an error.
formats`list[str]None` = None
mode`strNone` = None
encoding`strNone` = None
errors`strNone` = "strict"
lazy`boolNone` = None
atomicbool = FalseIf true, file writes are performed to a temporary file and moved to the destination upon completion to prevent data loss.
existsbool = FalseIf true, validates that the provided path already exists on the filesystem.
file_okaybool = TrueDetermines if a file path is a valid input for this argument.
dir_okaybool = TrueDetermines if a directory path is a valid input for this argument.
writablebool = FalseIf true, validates that the user has write permissions for the provided path.
readablebool = TrueIf true, validates that the user has read permissions for the provided path.
resolve_pathbool = FalseIf true, converts the provided path to an absolute path before passing it to the function.
allow_dashbool = FalseIf true, allows a single dash '-' to represent stdin or stdout.
path_type`Nonetype[str]
rich_help_panel`strNone` = None

Returns

TypeDescription
AnyA TyperArgument instance used by the internal parser to define a positional command-line parameter.