Closed
Description
"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)