Strongly typed, zero-effort CLIs
Project description
dcargs
dcargs
is a library for typed CLI interfaces and configuration objects.
pip install dcargs
Our core interface generates argument parsers from type-annotated callables. In
the simplest case, 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)
|
The broader goal is to enable replacing configuration frameworks like hydra
,
gin-config
, and ml_collections
with hierarchical structures built using
standard Python dataclasses and type annotations.
For a full list of features and usage 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.9.tar.gz
(28.0 kB
view hashes)
Built Distribution
dcargs-0.1.9-py3-none-any.whl
(32.6 kB
view hashes)