test em
This commit is contained in:
parent
daf81343bf
commit
a2b33b25f8
11 changed files with 479 additions and 55 deletions
|
|
@ -10,12 +10,12 @@ from learn_sql_model.cli.tui import tui_app
|
|||
|
||||
app = typer.Typer(
|
||||
name="learn_sql_model",
|
||||
help="A rich terminal report for coveragepy.",
|
||||
help="learn-sql-model cli for managing the project",
|
||||
)
|
||||
app.add_typer(config_app)
|
||||
app.add_typer(tui_app)
|
||||
app.add_typer(model_app)
|
||||
app.add_typer(api_app)
|
||||
app.add_typer(config_app, name="config")
|
||||
app.add_typer(tui_app, name="tui")
|
||||
app.add_typer(model_app, name="model")
|
||||
app.add_typer(api_app, name="api")
|
||||
app.add_typer(hero_app, name="hero")
|
||||
|
||||
|
||||
|
|
@ -38,6 +38,17 @@ def version_callback(value: bool) -> None:
|
|||
raise typer.Exit()
|
||||
|
||||
|
||||
@app.callback()
|
||||
def main(
|
||||
version: bool = typer.Option(
|
||||
False,
|
||||
callback=version_callback,
|
||||
help="show the version of the learn-sql-model package.",
|
||||
),
|
||||
):
|
||||
"configuration cli"
|
||||
|
||||
|
||||
@app.command()
|
||||
def tui(ctx: typer.Context) -> None:
|
||||
Trogon(get_group(app), click_context=ctx).run()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from typing import List, Union
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from pydantic_typer import expand_pydantic_args
|
||||
from rich.console import Console
|
||||
|
|
@ -9,6 +9,7 @@ from learn_sql_model.factories.hero import HeroFactory
|
|||
from learn_sql_model.factories.pet import PetFactory
|
||||
from learn_sql_model.models.hero import Hero
|
||||
from learn_sql_model.models.pet import Pet
|
||||
import sys
|
||||
|
||||
hero_app = typer.Typer()
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ def hero():
|
|||
@hero_app.command()
|
||||
@expand_pydantic_args(typer=True)
|
||||
def get(
|
||||
id: int = None,
|
||||
id: Optional[int] = None,
|
||||
config: Config = None,
|
||||
) -> Union[Hero, List[Hero]]:
|
||||
"get one hero"
|
||||
|
|
@ -52,12 +53,11 @@ def populate(
|
|||
config: Config = None,
|
||||
) -> Hero:
|
||||
"read all the heros"
|
||||
config.init()
|
||||
if config is None:
|
||||
config = Config()
|
||||
if config.env == "prod":
|
||||
Console().print("populate is not supported in production")
|
||||
return
|
||||
sys.exit(1)
|
||||
|
||||
for hero in HeroFactory().batch(n):
|
||||
pet = PetFactory().build()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue