init
This commit is contained in:
commit
4be274d9e2
39 changed files with 2548 additions and 0 deletions
30
learn_sql_model/cli/hero.py
Normal file
30
learn_sql_model/cli/hero.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue