A library for building simple CLIs from dataclasses
Project description
datacli
datacli
is a library for building simple command line interfaces from
dataclasses. It is built on argparse
and has no dependencies.
Usage
A picture code snippet speaks a thousand words:
# person.py
from dataclasses import dataclass, field
from datacli import datacli
@dataclass
class Person:
name: str
age: int = 30
args = datacli(Person)
print(args)
$ python person.py --name "Jeremy"
Person(name="Jeremy", age=30)
$ python person.py --name "Jeremy" --age 20
Person(name="Jeremy", age=20)
$ python person.py --help
usage: test.py [-h] --name NAME [--age AGE]
optional arguments:
-h, --help show this help message and exit
--name NAME
--age AGE
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
dataclass-cli-0.1.0.tar.gz
(2.0 kB
view hashes)