-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
In the case where I have something like this
class MyParams(BaseModel):
foo: int
bar: str
def main(params: MyParams):
typer.echo(f"{params.foo}")
if __name__ == "__main__":
pydantic_typer.run(main)I would like to generate a CLI with arguments --foo and --bar directly instead of --params.foo and --params.bar.
In other words, I would like to define the set of parameters externally, using a pydantic model.
Is this possible?
The reason why I want to do that is that I have a bunch of BaseModel that define the arguments of multiple commands. And I would like to automatically generate the CLI based an these pydantic models.
A second question then is: how can I programmatically generate CLI commands with arguments defined by pydantic models?
Thanks a lot for your work on this extension!
gbrandt1 and saroad2
Metadata
Metadata
Assignees
Labels
No labels