edornd / argdantic

Typed command line interfaces with argparse and pydantic
MIT License
40 stars 4 forks source link

Refactor dynamic sources #54

Closed edornd closed 1 month ago

edornd commented 2 months ago

The current API based on custom models works, but it's not extremely elegant. I think it might be better to pass from a decorator such as:

@from_file(...)
class Config(BaseModel):
    foo: int
    bar: str

This should automatically add an extra field to gather a config from a file, defined at runtime via CLI. It could also allow more flexibility, for instance it could allow selecting a model field for that purpose.