wip
This commit is contained in:
parent
347418ee3f
commit
b8a9ea0f17
6 changed files with 63 additions and 18 deletions
|
|
@ -6,6 +6,7 @@ from learn_sql_model.cli.api import api_app
|
|||
from learn_sql_model.cli.config import config_app
|
||||
from learn_sql_model.cli.hero import hero_app
|
||||
from learn_sql_model.cli.model import model_app
|
||||
from learn_sql_model.game.game import game_app
|
||||
|
||||
app = typer.Typer(
|
||||
name="learn_sql_model",
|
||||
|
|
@ -16,6 +17,7 @@ app.add_typer(config_app, name="config")
|
|||
app.add_typer(model_app, name="model")
|
||||
app.add_typer(api_app, name="api")
|
||||
app.add_typer(hero_app, name="hero")
|
||||
app.add_typer(game_app, name="game")
|
||||
|
||||
|
||||
def version_callback(value: bool) -> None:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from contextvars import ContextVar
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
from fastapi import Depends
|
||||
from pydantic import BaseModel, BaseSettings
|
||||
from pydantic import BaseModel, BaseSettings, validator
|
||||
from sqlalchemy import create_engine
|
||||
from sqlmodel import SQLModel, Session
|
||||
|
||||
|
|
@ -61,6 +61,12 @@ class Config(BaseSettings):
|
|||
env_nested_delimiter = "__"
|
||||
env_file = ".env", ".env.dev", ".env.qa", ".env.prod"
|
||||
|
||||
@validator("database_url")
|
||||
def validate_database_url(cls, v: str) -> str:
|
||||
if v.startswith("postgres://"):
|
||||
return v.replace("postgres://", "postgresql+psycopg2://")
|
||||
return v
|
||||
|
||||
@property
|
||||
def database(self) -> Database:
|
||||
return get_database(config=self)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
# using pygame make a game using Hero
|
||||
# it should be gamepad and mouse compatible
|
||||
# it should have a server that keeps track of the game logic
|
||||
# it should have a renderer that renders the game
|
||||
# it should have a client that sends commands to the server
|
||||
#
|
||||
|
||||
|
||||
import atexit
|
||||
|
||||
from faker import Faker
|
||||
import pygame
|
||||
import typer
|
||||
from typer import Typer
|
||||
from websocket import create_connection
|
||||
|
||||
|
|
@ -49,7 +41,7 @@ class Client:
|
|||
def ws(self):
|
||||
def connect():
|
||||
self._ws = create_connection(
|
||||
f"ws://{config.api_client.host}:{config.api_client.port}/wsecho"
|
||||
f"ws://{config.api_client.url.replace('https://', '')}/wsecho"
|
||||
)
|
||||
|
||||
if not hasattr(self, "_ws"):
|
||||
|
|
@ -176,17 +168,17 @@ class Client:
|
|||
pass
|
||||
|
||||
|
||||
app = Typer()
|
||||
game_app = Typer()
|
||||
|
||||
|
||||
@app.command()
|
||||
def run(
|
||||
name: str = typer.Option(...),
|
||||
secret_name: str = typer.Option(...),
|
||||
):
|
||||
@game_app.command()
|
||||
def run():
|
||||
f = Faker()
|
||||
name = "-".join(f.words(2))
|
||||
secret_name = "-".join(f.words(2))
|
||||
client = Client(name, secret_name)
|
||||
client.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
game_app()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue