Pydantic CLI Models
Pydantic + Click == Perfection (with love to Rust's clap library)
Github
Issues
Reduce boilerplate by 2x (at least), turning this:
import click
from pydantic import BaseModel
class Person(BaseModel):
name: str
age: int
@click.command()
@click.option("--name", type=str)
@click.option("--age", type=int)
def main(name, age):
person = Person(name=name, age=age)
Into this:
from pydantic_cli_model import CLIModel
class Person(CLIModel):
name: str
age: int
@Person.cli
def main(person:Person):
...
And get data validation for free!