This commit is contained in:
Waylon Walker 2023-05-19 08:35:16 -05:00
commit 4be274d9e2
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
39 changed files with 2548 additions and 0 deletions

View file

@ -0,0 +1,30 @@
from typing import List, Union
from pydantic_typer import expand_pydantic_args
from rich.console import Console
import typer
from learn_sql_model.models import Hero
hero_app = typer.Typer()
@hero_app.callback()
def hero():
"model cli"
@hero_app.command()
def get(id: int = None) -> Union[Hero, List[Hero]]:
"get one hero"
hero = Hero.get(item_id=id)
Console().print(hero)
return hero
@hero_app.command()
@expand_pydantic_args(typer=True)
def create(hero: Hero) -> Hero:
"read all the heros"
hero = hero.post()
Console().print(hero)