Skip to content

Commit d32eb69

Browse files
committed
Fix start command logic
1 parent 40892dc commit d32eb69

4 files changed

Lines changed: 195 additions & 219 deletions

File tree

fastapi_forge/__main__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,35 @@ def main() -> None:
3232
help="PostgreSQL connection URL (e.g., postgresql://user:password@host:port/dbname)",
3333
)
3434
def start(
35-
use_example: bool,
36-
no_ui: bool,
35+
use_example: bool = False,
36+
no_ui: bool = False,
3737
from_yaml: str | None = None,
3838
db_url: str | None = None,
3939
) -> None:
4040
"""Start the FastAPI Forge server and generate a new project."""
41-
if sum([use_example, bool(from_yaml), bool(db_url)]) > 1:
41+
option_count = sum([use_example, bool(from_yaml), bool(db_url)])
42+
if option_count > 1:
4243
msg = "Only one of '--use-example', '--from-yaml', or '--db-url' can be used."
4344
raise click.UsageError(msg)
4445

46+
if no_ui and option_count < 1:
47+
msg = "Option '--no-ui' requires one of '--use-example', '--from-yaml', or '--db-url' to be set."
48+
raise click.UsageError(msg)
49+
4550
project_spec = None
4651

4752
if from_yaml:
4853
yaml_path = Path(from_yaml).expanduser().resolve()
4954
if not yaml_path.is_file():
5055
raise click.FileError(f"YAML file not found: {yaml_path}")
5156
project_spec = ProjectLoader(project_path=yaml_path).load_project_input()
52-
5357
elif db_url:
5458
project_spec = ProjectLoader.load_project_spec_from_db(
5559
connection_string=db_url,
5660
)
57-
58-
else:
61+
elif use_example:
5962
base_path = Path(__file__).parent / "example-projects"
60-
path = base_path / ("game_zone.yaml" if use_example else "empty-service.yaml")
63+
path = base_path / "game_zone.yaml"
6164
project_spec = ProjectLoader(project_path=path).load_project_input()
6265

6366
init(project_spec=project_spec, no_ui=no_ui)

fastapi_forge/enums.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
from enum import StrEnum
22

33

4-
class HTTPMethod(StrEnum):
5-
GET = "get"
6-
GET_ID = "get_id"
7-
POST = "post"
8-
PATCH = "patch"
9-
DELETE = "delete"
10-
11-
124
class FieldDataType(StrEnum):
135
STRING = "String"
146
INTEGER = "Integer"
@@ -18,17 +10,6 @@ class FieldDataType(StrEnum):
1810
UUID = "UUID"
1911
JSONB = "JSONB"
2012

21-
def as_python_type(self) -> str:
22-
return {
23-
FieldDataType.STRING: "str",
24-
FieldDataType.INTEGER: "int",
25-
FieldDataType.FLOAT: "float",
26-
FieldDataType.BOOLEAN: "bool",
27-
FieldDataType.DATETIME: "datetime",
28-
FieldDataType.UUID: "UUID",
29-
FieldDataType.JSONB: "dict[str, Any]",
30-
}[self]
31-
3213
@classmethod
3314
def from_db_type(cls, db_type: str) -> "FieldDataType":
3415
db_type = db_type.lower()

fastapi_forge/example-projects/empty-service.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)