Metadata-Version: 2.3
Name: pydantic-argparse
Version: 0.9.0
Summary: Typed Argument Parsing with Pydantic
Project-URL: Homepage, https://pydantic-argparse.supimdos.com
Project-URL: Documentation, https://pydantic-argparse.supimdos.com
Project-URL: Changelog, https://github.com/SupImDos/pydantic-argparse/blob/master/CHANGELOG.md
Project-URL: Repository, https://github.com/SupImDos/pydantic-argparse
Project-URL: Issues, https://github.com/SupImDos/pydantic-argparse/issues
Author-email: Hayden Richards <supimdos@gmail.com>
License: MIT License
        
        Copyright (c) 2021 Hayden Richards
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: argparse,pydantic,python,typed,validation
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pydantic
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Requires-Dist: pydantic
Description-Content-Type: text/markdown

<div align="center">
    <a href="https://pydantic-argparse.supimdos.com">
        <img src="https://raw.githubusercontent.com/SupImDos/pydantic-argparse/master/docs/assets/images/logo.svg" width="50%">
    </a>
    <h1>
        Pydantic Argparse
    </h1>
    <p>
        <em>Typed Argument Parsing with Pydantic</em>
    </p>
    <a href="https://pypi.python.org/pypi/pydantic-argparse">
        <img src="https://img.shields.io/pypi/v/pydantic-argparse.svg">
    </a>
    <a href="https://pepy.tech/project/pydantic-argparse">
        <img src="https://pepy.tech/badge/pydantic-argparse">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse">
        <img src="https://img.shields.io/pypi/pyversions/pydantic-argparse.svg">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/blob/master/LICENSE">
        <img src="https://img.shields.io/github/license/SupImDos/pydantic-argparse.svg">
    </a>
    <br>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/tests.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/tests.yml?label=tests">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/tests.yml">
        <img src="https://img.shields.io/coveralls/github/SupImDos/pydantic-argparse">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/linting.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/linting.yml?label=linting">
    </a>
    <a href="https://github.com/SupImDos/pydantic-argparse/actions/workflows/typing.yml">
        <img src="https://img.shields.io/github/actions/workflow/status/supimdos/pydantic-argparse/typing.yml?label=typing">
    </a>
</div>

## Help
See [documentation](https://pydantic-argparse.supimdos.com) for help.

## Requirements
Requires Python 3.8+, and is compatible with the Pydantic v1 API.

## Installation
Installation with `pip` is simple:
```console
$ pip install pydantic-argparse
```

## Example
```py
import pydantic.v1 as pydantic
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")

    # Optional Args
    second_flag: bool = pydantic.Field(False, description="an optional flag")
    third_flag: bool = pydantic.Field(True, description="an optional flag")


def main() -> None:
    # Create Parser and Parse Args
    parser = pydantic_argparse.ArgumentParser(
        model=Arguments,
        prog="Example Program",
        description="Example Description",
        version="0.0.1",
        epilog="Example Epilog",
    )
    args = parser.parse_typed_args()

    # Print Args
    print(args)


if __name__ == "__main__":
    main()
```

```console
$ python3 example.py --help
usage: Example Program [-h] [-v] --string STRING --integer INTEGER --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

optional arguments:
  --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

Example Epilog
```

```console
$ python3 example.py --string hello --integer 42 --flag
string='hello' integer=42 flag=True second_flag=False third_flag=True
```

## License
This project is licensed under the terms of the MIT license.
