args
Arg(default=PydanticUndefined, *, help, positional=None, required=None, aliases=None, nargs=None, validator=None)
¶
Create a pydantic Field
.
Field docs: https://docs.pydantic.dev/2.2/usage/fields
Defines properties used to create an argparse argument. This function
should work for most cases. If we need something that is not covered
we can use ArgProxy
instead which is untyped but provides all the arguments
and keyword arguments to argparse.
See https://docs.python.org/3/library/argparse.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default |
Any
|
Default value if the field is not set. |
PydanticUndefined
|
help |
str
|
Human-readable description. |
required |
positional |
bool | None
|
Whether the argument is positional or not. |
None
|
required |
bool | None
|
Indicate whether an argument is required or optional. |
None
|
aliases |
list[str] | None
|
Alternative names for the argument. |
None
|
nargs |
int | Literal['?', '*', '+'] | None
|
Number of times the argument can be used. |
None
|
validator |
Callable[[str], str] | None
|
Function to validate the argument. |
None
|
Returns:
Type | Description |
---|---|
Any
|
A new |
Source code in m/cli/args.py
ArgProxy(*args, **kwargs)
¶
Wrap function to provide all argparse inputs.
This is a escape hatch and does not provide any typings. See https://docs.python.org/3/library/argparse.html.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Any
|
The arguments to argparse add_arguments. |
()
|
kwargs |
Any
|
The keyword arguments to argparse add arguments. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
A new |
Source code in m/cli/args.py
Meta(*, help, description)
¶
Create the meta dictionary for a subcommand description.
In the case of the root command the help
may be set to empty since it
is not used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
help |
str
|
The help message for the subcommand. |
required |
description |
str
|
The description for the command/subcommand. |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
A dictionary with the help and description. |
Source code in m/cli/args.py
RemainderArgs(*, help=_Unset)
¶
Provide a list of unrecognized arguments.
This is a escape hatch and does not provide any typings. May be useful for commands that need to pass arguments to other commands.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
help |
str | None
|
Human-readable description. |
_Unset
|
Returns:
Type | Description |
---|---|
Any
|
A new |
Any
|
|