Open
Description
Hi, is there a way to directly construct a dataclass from the command line inputs with typer? Like an argparser would do.
For a large amount of arguments this would improve readability of the code, and would permit inheritances of dataclasses like in the example below:
import typer
from dataclasses import dataclass
@dataclass
class BaseFlags:
arg1: int = typer.Argument(help='something', default=1)
arg2: int = typer.Argument(help='something', default=2)
@dataclass
class Flags(BaseFlags):
arg3: int = typer.Argument(help='something', default=3)
arg4: int = typer.Argument(help='something', default=4)
def main(args:Flags=Flags()):
print(args)
if __name__ == '__main__':
typer.run(main)
Thanks a lot for the great package and your help!