Skip to main content

Strongly typed, zero-effort CLIs

Project description

dcargs

Documentation   •   pip install dcargs

build mypy lint codecov codecov

dcargs is a library for typed CLI interfaces and configuration objects.

Our core interface, dcargs.cli(), generates argument parsers from type-annotated
callables: functions, classes, dataclasses, and nested dataclasses and classes.

This can be used as a drop-in replacement for argparse:

with argparse with dcargs
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)
import dcargs

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

dcargs.cli(main)

For more sophisticated examples, see our documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcargs-0.1.10.tar.gz (28.0 kB view hashes)

Uploaded Source

Built Distribution

dcargs-0.1.10-py3-none-any.whl (32.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page