|
1 | | -import sys |
2 | | -from pathlib import Path |
3 | | - |
4 | 1 | import click |
5 | 2 |
|
6 | 3 | from fastapi_forge.api import start_forge_api |
7 | | -from fastapi_forge.frontend.main import init |
8 | | -from fastapi_forge.project_io import ( |
9 | | - YamlProjectLoader, |
10 | | - create_postgres_project_loader, |
11 | | -) |
12 | 4 |
|
13 | 5 |
|
14 | 6 | def confirm_uv_installed() -> bool: |
@@ -56,84 +48,82 @@ def start() -> None: |
56 | 48 | start_forge_api() |
57 | 49 |
|
58 | 50 |
|
59 | | -@main.command( |
60 | | - help="Start FastAPI Forge - Generate a new FastAPI project.", |
61 | | -) |
62 | | -@click.option( |
63 | | - "--use-example", |
64 | | - is_flag=True, |
65 | | - help="Generate a new project using a prebuilt example provided by FastAPI Forge.", |
66 | | -) |
67 | | -@click.option( |
68 | | - "--no-ui", |
69 | | - is_flag=True, |
70 | | - help="Generate the project directly in the terminal without launching the UI (default: False).", |
71 | | -) |
72 | | -@click.option( |
73 | | - "--dry-run", |
74 | | - is_flag=True, |
75 | | - help="Perform a dry run without generating any files (requires --no-ui).", |
76 | | -) |
77 | | -@click.option( |
78 | | - "--from-yaml", |
79 | | - type=click.Path( |
80 | | - exists=True, |
81 | | - dir_okay=False, |
82 | | - readable=True, |
83 | | - path_type=Path, |
84 | | - ), |
85 | | - help="Generate a project using a custom configuration from a YAML file.", |
86 | | -) |
87 | | -@click.option( |
88 | | - "--yes", |
89 | | - is_flag=True, |
90 | | - help="Automatically confirm all prompts (use with caution).", |
91 | | -) |
92 | | -@click.option( |
93 | | - "--conn-string", |
94 | | - help="Generate a project from a PostgreSQL connection string " |
95 | | - "(e.g., postgresql://user:password@host:port/dbname)", |
96 | | -) |
97 | | -@click.pass_context |
98 | | -def start_v1( |
99 | | - _: click.Context, |
100 | | - use_example: bool = False, |
101 | | - no_ui: bool = False, |
102 | | - dry_run: bool = False, |
103 | | - yes: bool = False, |
104 | | - from_yaml: Path | None = None, |
105 | | - conn_string: str | None = None, |
106 | | -) -> None: |
107 | | - """Start FastAPI Forge.""" |
108 | | - if not yes and not confirm_uv_installed(): |
109 | | - sys.exit(1) |
110 | | - |
111 | | - option_count = sum([use_example, bool(from_yaml), bool(conn_string)]) |
112 | | - if option_count > 1: |
113 | | - raise click.UsageError( |
114 | | - "Only one of '--use-example', '--from-yaml', or '--conn-string' can be used." |
115 | | - ) |
116 | | - |
117 | | - if no_ui and option_count < 1: |
118 | | - raise click.UsageError( |
119 | | - "Option '--no-ui' requires one of '--use-example', '--from-yaml', or '--conn-string'." |
120 | | - ) |
121 | | - |
122 | | - if dry_run and not no_ui: |
123 | | - raise click.UsageError("Option '--dry-run' requires '--no-ui' to be set.") |
124 | | - |
125 | | - project_spec = None |
126 | | - |
127 | | - if from_yaml: |
128 | | - project_spec = YamlProjectLoader(project_path=from_yaml).load() |
129 | | - elif conn_string: |
130 | | - project_spec = create_postgres_project_loader(conn_string).load() |
131 | | - elif use_example: |
132 | | - base_path = Path(__file__).parent / "example-projects" |
133 | | - path = base_path / "game_zone.yaml" |
134 | | - project_spec = YamlProjectLoader(project_path=path).load() |
135 | | - |
136 | | - init(project_spec=project_spec, no_ui=no_ui, dry_run=dry_run) |
| 51 | +# @main.command( |
| 52 | +# help="Start FastAPI Forge - Generate a new FastAPI project.", |
| 53 | +# ) |
| 54 | +# @click.option( |
| 55 | +# "--use-example", |
| 56 | +# is_flag=True, |
| 57 | +# help="Generate a new project using a prebuilt example provided by FastAPI Forge.", |
| 58 | +# ) |
| 59 | +# @click.option( |
| 60 | +# "--no-ui", |
| 61 | +# is_flag=True, |
| 62 | +# help="Generate the project directly in the terminal without launching the UI (default: False).", |
| 63 | +# ) |
| 64 | +# @click.option( |
| 65 | +# "--dry-run", |
| 66 | +# is_flag=True, |
| 67 | +# help="Perform a dry run without generating any files (requires --no-ui).", |
| 68 | +# ) |
| 69 | +# @click.option( |
| 70 | +# "--from-yaml", |
| 71 | +# type=click.Path( |
| 72 | +# exists=True, |
| 73 | +# dir_okay=False, |
| 74 | +# readable=True, |
| 75 | +# path_type=Path, |
| 76 | +# ), |
| 77 | +# help="Generate a project using a custom configuration from a YAML file.", |
| 78 | +# ) |
| 79 | +# @click.option( |
| 80 | +# "--yes", |
| 81 | +# is_flag=True, |
| 82 | +# help="Automatically confirm all prompts (use with caution).", |
| 83 | +# ) |
| 84 | +# @click.option( |
| 85 | +# "--conn-string", |
| 86 | +# help="Generate a project from a PostgreSQL connection string " |
| 87 | +# "(e.g., postgresql://user:password@host:port/dbname)", |
| 88 | +# ) |
| 89 | +# @click.pass_context |
| 90 | +# def start_v1( |
| 91 | +# _: click.Context, |
| 92 | +# use_example: bool = False, |
| 93 | +# no_ui: bool = False, |
| 94 | +# dry_run: bool = False, |
| 95 | +# yes: bool = False, |
| 96 | +# from_yaml: Path | None = None, |
| 97 | +# conn_string: str | None = None, |
| 98 | +# ) -> None: |
| 99 | +# """Start FastAPI Forge.""" |
| 100 | +# if not yes and not confirm_uv_installed(): |
| 101 | +# sys.exit(1) |
| 102 | + |
| 103 | +# option_count = sum([use_example, bool(from_yaml), bool(conn_string)]) |
| 104 | +# if option_count > 1: |
| 105 | +# raise click.UsageError( |
| 106 | +# "Only one of '--use-example', '--from-yaml', or '--conn-string' can be used." |
| 107 | +# ) |
| 108 | + |
| 109 | +# if no_ui and option_count < 1: |
| 110 | +# raise click.UsageError( |
| 111 | +# "Option '--no-ui' requires one of '--use-example', '--from-yaml', or '--conn-string'." |
| 112 | +# ) |
| 113 | + |
| 114 | +# if dry_run and not no_ui: |
| 115 | +# raise click.UsageError("Option '--dry-run' requires '--no-ui' to be set.") |
| 116 | + |
| 117 | +# project_spec = None |
| 118 | + |
| 119 | +# if from_yaml: |
| 120 | +# project_spec = YamlProjectLoader(project_path=from_yaml).load() |
| 121 | +# elif conn_string: |
| 122 | +# project_spec = create_postgres_project_loader(conn_string).load() |
| 123 | +# elif use_example: |
| 124 | +# base_path = Path(__file__).parent / "example-projects" |
| 125 | +# path = base_path / "game_zone.yaml" |
| 126 | +# project_spec = YamlProjectLoader(project_path=path).load() |
137 | 127 |
|
138 | 128 |
|
139 | 129 | if __name__ in {"__main__", "__mp_main__"}: |
|
0 commit comments