"Short" args (or aliases) are useful in commanding tools. For example --name could have an alias of -n.
Acceptance Criteria
Enable short args using AliasChoices that are 1 char (e.g., n should translate to -n. Currently, these translate to --n).
The usage:... string should contain the full name
Update docs to include an example
Example:
from pydantic import Field, AliasChoices
from pydantic_settings import BaseSettings
class Settings(BaseSettings, cli_parse_args=True):
name: str = Field(validation_alias=AliasChoices('n', 'name'))
age: int
Yields:
usage: example.py [-h] [--n str] [--age int]
options:
-h, --help show this help message and exit
--n str, --name str (required)
--age int (required)
It should return:
usage: example.py [-h] [--name str] [--age int]
options:
-h, --help show this help message and exit
-n str, --name str (required)
--age int (required)
Thanks @mpkocher, that's a great suggestion to use single string aliases implicitly as short flags... I'll take a peek when I get a chance, but that should be pretty straightforward to add.
"Short" args (or aliases) are useful in commanding tools. For example
--name
could have an alias of-n
.Acceptance Criteria
AliasChoices
that are 1 char (e.g.,n
should translate to-n
. Currently, these translate to--n
).usage:...
string should contain the full nameExample:
Yields:
It should return: