Metadata-Version: 2.1
Name: dcargs
Version: 0.3.13
Summary: Strongly typed, zero-effort CLI interfaces
Home-page: https://github.com/brentyi/dcargs
Author: brentyi
Author-email: brentyi@berkeley.edu
Requires-Python: >=3.7,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: PyYAML (>=6.0,<7.0)
Requires-Dist: backports.cached-property (>=1.0.2,<2.0.0); python_version >= "3.7" and python_version < "3.8"
Requires-Dist: colorama (>=0.4.0,<0.5.0); sys_platform == "win32"
Requires-Dist: docstring-parser (>=0.14.1,<0.15.0)
Requires-Dist: frozendict (>=2.3.4,<3.0.0)
Requires-Dist: rich (>=11.1.0)
Requires-Dist: typing-extensions (>=4.3.0,<5.0.0)
Project-URL: Documentation, https://brentyi.github.io/dcargs/
Project-URL: Repository, https://github.com/brentyi/dcargs
Description-Content-Type: text/markdown

<h1 align="">dcargs</h1>

<p align="">
    <em><a href="https://brentyi.github.io/dcargs">Documentation</a></em>
    &nbsp;&nbsp;&bull;&nbsp;&nbsp;
    <em><code>pip install dcargs</code></em>
</p>
<p align="">
    <img alt="build" src="https://github.com/brentyi/dcargs/workflows/build/badge.svg" />
    <img alt="mypy" src="https://github.com/brentyi/dcargs/workflows/mypy/badge.svg?branch=master" />
    <img alt="lint" src="https://github.com/brentyi/dcargs/workflows/lint/badge.svg" />
    <a href="https://codecov.io/gh/brentyi/dcargs">
        <img alt="codecov" src="https://codecov.io/gh/brentyi/dcargs/branch/master/graph/badge.svg" />
    </a>
    <a href="https://pypi.org/project/dcargs/">
        <img alt="codecov" src="https://img.shields.io/pypi/pyversions/dcargs" />
    </a>
</p>

<p align="">
    <strong><code>dcargs</code></strong> is a library for typed CLI interfaces
    and configuration objects.
</p>

<p align="">
    Our core interface, <code>dcargs.cli()</code>, generates argument parsers from type-annotated
    <br />callables: functions, dataclasses, classes, and <em>nested</em> dataclasses and classes.
</p>

<p align="">
    This can be used as a replacement for <code>argparse</code>:
</p>

<table align="">
<tr>
    <td><strong>with argparse</strong></td>
    <td><strong>with dcargs</strong></td>
</tr>
<tr>
<td>

```python
"""Sum two numbers from argparse."""

import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
    "--a",
    type=int,
    required=True,
)
parser.add_argument(
    "--b",
    type=int,
    default=3,
)
args = parser.parse_args()

print(args.a + args.b)
```

</td>
<td>

```python
"""Sum two numbers by calling a
function with dcargs."""

import dcargs

def main(a: int, b: int = 3) -> None:
    print(a + b)

dcargs.cli(main)
```

---

```python
"""Sum two numbers by instantiating
a dataclass with dcargs."""

from dataclasses import dataclass

import dcargs

@dataclass
class Args:
    a: int
    b: int = 3

args = dcargs.cli(Args)
print(args.a + args.b)
```

</td>
</tr>
</table>

<p align="">
    For more sophisticated examples, see
    <a href="https://brentyi.github.io/dcargs">our documentation</a>.
</p>

