Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/techui_builder/schema_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
from pathlib import Path

import typer
Expand All @@ -9,7 +10,8 @@
)

SCHEMAS_DIR = Path("schemas")
SCHEMAS_DIR.mkdir(exist_ok=True)

logger_ = logging.getLogger(__name__)

app = typer.Typer(context_settings={"allow_interspersed_args": True})

Expand All @@ -26,6 +28,13 @@ def write_json_schema(model_name: str, schema_dict: dict) -> None:
invoke_without_command=True,
)
def schema_generator() -> None:
if not SCHEMAS_DIR.exists():
try:
SCHEMAS_DIR.mkdir()
except OSError:
logger_.critical("Unable to make schemas dir.")
exit()

# techui
tu = TechUi.model_json_schema()
write_json_schema("techui", tu)
Expand Down