@@ -39,9 +39,9 @@ import pydantic_argparse
3939
4040class Arguments (pydantic .BaseModel ):
4141 # Required Args
42- string: str = pydantic.Field(description = " a required string" )
43- integer: int = pydantic.Field(description = " a required integer" )
44- flag: bool = pydantic.Field(description = " a required flag" )
42+ string: str = pydantic.Field(description = " a required string" , aliases = [ " -s " ] )
43+ integer: int = pydantic.Field(description = " a required integer" , aliases = [ " -i " ] )
44+ flag: bool = pydantic.Field(description = " a required flag" , aliases = [ " -f " ] )
4545
4646 # Optional Args
4747 second_flag: bool = pydantic.Field(False , description = " an optional flag" )
@@ -69,29 +69,32 @@ if __name__ == "__main__":
6969
7070``` console
7171$ python3 example.py --help
72- usage: Example Program [-h] [-v] --string STRING --integer INTEGER -- flag |
73- --no-flag [--second-flag] [--no-third-flag]
72+ usage: Example Program [-h] [-v] [-s STRING] [-i INTEGER] [-f | -- flag | --no-flag]
73+ [--second-flag] [--no-third-flag]
7474
7575Example Description
7676
7777required arguments:
78- --string STRING a required string
79- --integer INTEGER a required integer
80- --flag, --no-flag a required flag
78+ -s STRING, --string STRING
79+ a required string
80+ -i INTEGER, --integer INTEGER
81+ a required integer
82+ -f, --flag, --no-flag
83+ a required flag
8184
8285optional arguments:
83- --second-flag an optional flag (default: False)
84- --no-third-flag an optional flag (default: True)
86+ --second-flag an optional flag (default: False)
87+ --no-third-flag an optional flag (default: True)
8588
8689help:
87- -h, --help show this help message and exit
88- -v, --version show program's version number and exit
90+ -h, --help show this help message and exit
91+ -v, --version show program's version number and exit
8992
9093Example Epilog
9194```
9295
9396``` console
94- $ python3 example.py --string hello --integer 42 --flag
97+ $ python3 example.py --string hello -i 42 -f
9598string='hello' integer=42 flag=True second_flag=False third_flag=True
9699```
97100
0 commit comments