pass the tests
This commit is contained in:
parent
0eb29bdc10
commit
daf81343bf
3 changed files with 64 additions and 13 deletions
|
|
@ -2,10 +2,9 @@ from typing import List, Union
|
|||
|
||||
from pydantic_typer import expand_pydantic_args
|
||||
from rich.console import Console
|
||||
from sqlmodel import SQLModel
|
||||
import typer
|
||||
|
||||
from learn_sql_model.config import Config, get_config
|
||||
from learn_sql_model.config import Config
|
||||
from learn_sql_model.factories.hero import HeroFactory
|
||||
from learn_sql_model.factories.pet import PetFactory
|
||||
from learn_sql_model.models.hero import Hero
|
||||
|
|
@ -17,12 +16,16 @@ hero_app = typer.Typer()
|
|||
@hero_app.callback()
|
||||
def hero():
|
||||
"model cli"
|
||||
SQLModel.metadata.create_all(get_config().database.engine)
|
||||
|
||||
|
||||
@hero_app.command()
|
||||
def get(id: int = None) -> Union[Hero, List[Hero]]:
|
||||
@expand_pydantic_args(typer=True)
|
||||
def get(
|
||||
id: int = None,
|
||||
config: Config = None,
|
||||
) -> Union[Hero, List[Hero]]:
|
||||
"get one hero"
|
||||
config.init()
|
||||
hero = Hero().get(id=id)
|
||||
Console().print(hero)
|
||||
return hero
|
||||
|
|
@ -36,6 +39,7 @@ def create(
|
|||
config: Config = None,
|
||||
) -> Hero:
|
||||
"read all the heros"
|
||||
config.init()
|
||||
hero.pet = pet
|
||||
hero = hero.post(config=config)
|
||||
Console().print(hero)
|
||||
|
|
@ -48,6 +52,7 @@ def populate(
|
|||
config: Config = None,
|
||||
) -> Hero:
|
||||
"read all the heros"
|
||||
config.init()
|
||||
if config is None:
|
||||
config = Config()
|
||||
if config.env == "prod":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue