edornd / argdantic

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

Provide direct access to the validated model for peculiar use cases #31

Open edornd opened 1 year ago

edornd commented 1 year ago

There are a lot of options already available, however for any kind of use case it's probably a good idea to also have a way to provide the pydantic model. A simple concept could be to directly use the function, which (after decoration) is actually a Command instance:

@cli.command()
def foo(value: int):
    print(foo.model)

The idea of storing a reference to the model is not amazing, but I currently don't see drawbacks. It could also be made optional via flag argument, e.g. command(store_config=True), in the future to solve any possible issue.