Skip to content
Merged
Show file tree
Hide file tree
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
162 changes: 76 additions & 86 deletions fastapi_forge/cli/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import sys
from pathlib import Path

import click

from fastapi_forge.api import start_forge_api
from fastapi_forge.frontend.main import init
from fastapi_forge.project_io import (
YamlProjectLoader,
create_postgres_project_loader,
)


def confirm_uv_installed() -> bool:
Expand Down Expand Up @@ -56,84 +48,82 @@ def start() -> None:
start_forge_api()


@main.command(
help="Start FastAPI Forge - Generate a new FastAPI project.",
)
@click.option(
"--use-example",
is_flag=True,
help="Generate a new project using a prebuilt example provided by FastAPI Forge.",
)
@click.option(
"--no-ui",
is_flag=True,
help="Generate the project directly in the terminal without launching the UI (default: False).",
)
@click.option(
"--dry-run",
is_flag=True,
help="Perform a dry run without generating any files (requires --no-ui).",
)
@click.option(
"--from-yaml",
type=click.Path(
exists=True,
dir_okay=False,
readable=True,
path_type=Path,
),
help="Generate a project using a custom configuration from a YAML file.",
)
@click.option(
"--yes",
is_flag=True,
help="Automatically confirm all prompts (use with caution).",
)
@click.option(
"--conn-string",
help="Generate a project from a PostgreSQL connection string "
"(e.g., postgresql://user:password@host:port/dbname)",
)
@click.pass_context
def start_v1(
_: click.Context,
use_example: bool = False,
no_ui: bool = False,
dry_run: bool = False,
yes: bool = False,
from_yaml: Path | None = None,
conn_string: str | None = None,
) -> None:
"""Start FastAPI Forge."""
if not yes and not confirm_uv_installed():
sys.exit(1)

option_count = sum([use_example, bool(from_yaml), bool(conn_string)])
if option_count > 1:
raise click.UsageError(
"Only one of '--use-example', '--from-yaml', or '--conn-string' can be used."
)

if no_ui and option_count < 1:
raise click.UsageError(
"Option '--no-ui' requires one of '--use-example', '--from-yaml', or '--conn-string'."
)

if dry_run and not no_ui:
raise click.UsageError("Option '--dry-run' requires '--no-ui' to be set.")

project_spec = None

if from_yaml:
project_spec = YamlProjectLoader(project_path=from_yaml).load()
elif conn_string:
project_spec = create_postgres_project_loader(conn_string).load()
elif use_example:
base_path = Path(__file__).parent / "example-projects"
path = base_path / "game_zone.yaml"
project_spec = YamlProjectLoader(project_path=path).load()

init(project_spec=project_spec, no_ui=no_ui, dry_run=dry_run)
# @main.command(
# help="Start FastAPI Forge - Generate a new FastAPI project.",
# )
# @click.option(
# "--use-example",
# is_flag=True,
# help="Generate a new project using a prebuilt example provided by FastAPI Forge.",
# )
# @click.option(
# "--no-ui",
# is_flag=True,
# help="Generate the project directly in the terminal without launching the UI (default: False).",
# )
# @click.option(
# "--dry-run",
# is_flag=True,
# help="Perform a dry run without generating any files (requires --no-ui).",
# )
# @click.option(
# "--from-yaml",
# type=click.Path(
# exists=True,
# dir_okay=False,
# readable=True,
# path_type=Path,
# ),
# help="Generate a project using a custom configuration from a YAML file.",
# )
# @click.option(
# "--yes",
# is_flag=True,
# help="Automatically confirm all prompts (use with caution).",
# )
# @click.option(
# "--conn-string",
# help="Generate a project from a PostgreSQL connection string "
# "(e.g., postgresql://user:password@host:port/dbname)",
# )
# @click.pass_context
# def start_v1(
# _: click.Context,
# use_example: bool = False,
# no_ui: bool = False,
# dry_run: bool = False,
# yes: bool = False,
# from_yaml: Path | None = None,
# conn_string: str | None = None,
# ) -> None:
# """Start FastAPI Forge."""
# if not yes and not confirm_uv_installed():
# sys.exit(1)

# option_count = sum([use_example, bool(from_yaml), bool(conn_string)])
# if option_count > 1:
# raise click.UsageError(
# "Only one of '--use-example', '--from-yaml', or '--conn-string' can be used."
# )

# if no_ui and option_count < 1:
# raise click.UsageError(
# "Option '--no-ui' requires one of '--use-example', '--from-yaml', or '--conn-string'."
# )

# if dry_run and not no_ui:
# raise click.UsageError("Option '--dry-run' requires '--no-ui' to be set.")

# project_spec = None

# if from_yaml:
# project_spec = YamlProjectLoader(project_path=from_yaml).load()
# elif conn_string:
# project_spec = create_postgres_project_loader(conn_string).load()
# elif use_example:
# base_path = Path(__file__).parent / "example-projects"
# path = base_path / "game_zone.yaml"
# project_spec = YamlProjectLoader(project_path=path).load()


if __name__ in {"__main__", "__mp_main__"}:
Expand Down
Empty file removed fastapi_forge/frontend/__init__.py
Empty file.
Empty file.
30 changes: 0 additions & 30 deletions fastapi_forge/frontend/components/header.py

This file was deleted.

67 changes: 0 additions & 67 deletions fastapi_forge/frontend/components/item_create.py

This file was deleted.

Loading