diff --git a/README.md b/README.md index 69e4b7f..5c2dc87 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ import pydantic_argparse class Arguments(pydantic.BaseModel): # Required Args - string: str = pydantic.Field(description="a required string") - integer: int = pydantic.Field(description="a required integer") - flag: bool = pydantic.Field(description="a required flag") + string: str = pydantic.Field(description="a required string", aliases=["-s"]) + integer: int = pydantic.Field(description="a required integer", aliases=["-i"]) + flag: bool = pydantic.Field(description="a required flag", aliases=["-f"]) # Optional Args second_flag: bool = pydantic.Field(False, description="an optional flag") @@ -69,29 +69,32 @@ if __name__ == "__main__": ```console $ python3 example.py --help -usage: Example Program [-h] [-v] --string STRING --integer INTEGER --flag | - --no-flag [--second-flag] [--no-third-flag] +usage: Example Program [-h] [-v] [-s STRING] [-i INTEGER] [-f | --flag | --no-flag] + [--second-flag] [--no-third-flag] Example Description required arguments: - --string STRING a required string - --integer INTEGER a required integer - --flag, --no-flag a required flag + -s STRING, --string STRING + a required string + -i INTEGER, --integer INTEGER + a required integer + -f, --flag, --no-flag + a required flag optional arguments: - --second-flag an optional flag (default: False) - --no-third-flag an optional flag (default: True) + --second-flag an optional flag (default: False) + --no-third-flag an optional flag (default: True) help: - -h, --help show this help message and exit - -v, --version show program's version number and exit + -h, --help show this help message and exit + -v, --version show program's version number and exit Example Epilog ``` ```console -$ python3 example.py --string hello --integer 42 --flag +$ python3 example.py --string hello -i 42 -f string='hello' integer=42 flag=True second_flag=False third_flag=True ``` diff --git a/docs/examples/simple.md b/docs/examples/simple.md index 4811d84..4b26c0e 100644 --- a/docs/examples/simple.md +++ b/docs/examples/simple.md @@ -6,29 +6,32 @@ ### Check Help ```console $ python3 simple.py --help -usage: Example Program [-h] [-v] --string STRING --integer INTEGER --flag | - --no-flag [--second-flag] [--no-third-flag] +usage: Example Program [-h] [-v] [-s STRING] [-i INTEGER] [-f | --flag | --no-flag] + [--second-flag] [--no-third-flag] Example Description required arguments: - --string STRING a required string - --integer INTEGER a required integer - --flag, --no-flag a required flag + -s STRING, --string STRING + a required string + -i INTEGER, --integer INTEGER + a required integer + -f, --flag, --no-flag + a required flag optional arguments: - --second-flag an optional flag (default: False) - --no-third-flag an optional flag (default: True) + --second-flag an optional flag (default: False) + --no-third-flag an optional flag (default: True) help: - -h, --help show this help message and exit - -v, --version show program's version number and exit + -h, --help show this help message and exit + -v, --version show program's version number and exit Example Epilog ``` ### Parse Arguments ```console -$ python3 simple.py --string hello --integer 42 --flag +$ python3 simple.py --string hello -i 42 -f string='hello' integer=42 flag=True second_flag=False third_flag=True ``` diff --git a/examples/simple.py b/examples/simple.py index b177a22..3de0b37 100644 --- a/examples/simple.py +++ b/examples/simple.py @@ -9,9 +9,9 @@ class Arguments(pydantic.BaseModel): """Simple Command-Line Arguments.""" # Required Args - string: str = pydantic.Field(description="a required string") - integer: int = pydantic.Field(description="a required integer") - flag: bool = pydantic.Field(description="a required flag") + string: str = pydantic.Field(description="a required string", aliases=["-s"]) + integer: int = pydantic.Field(description="a required integer", aliases=["-i"]) + flag: bool = pydantic.Field(description="a required flag", aliases=["-f"]) # Optional Args second_flag: bool = pydantic.Field(False, description="an optional flag")