Strongly typed, zero-effort CLIs
Project description
dcargs
Documentation
•
pip install dcargs
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
Release history Release notifications | RSS feed
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)
Built Distribution
dcargs-0.1.10-py3-none-any.whl
(32.7 kB
view hashes)