Skip to content

Commit 8643771

Browse files
committed
Add UV installation confirmation prompt + --yes flag to skip prompts
1 parent b2da983 commit 8643771

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

fastapi_forge/__main__.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from pathlib import Path
23

34
import click
@@ -9,6 +10,33 @@
910
)
1011

1112

13+
def confirm_uv_installed() -> bool:
14+
"""Show UV requirement warning and get confirmation."""
15+
click.secho(
16+
"\n⚠️ Important Requirement (use the '--yes' option to skip)",
17+
fg="yellow",
18+
bold=True,
19+
)
20+
click.echo("Generated projects require UV to be installed.")
21+
click.secho(
22+
"GitHub: https://docs.astral.sh/uv/getting-started/installation",
23+
fg="blue",
24+
underline=True,
25+
)
26+
27+
if not click.confirm(
28+
"\nDo you have UV installed and ready to use?",
29+
default=True,
30+
):
31+
click.secho(
32+
"\n❌ Please install UV first and restart this command.",
33+
fg="red",
34+
)
35+
click.echo("Verify with: uv --version")
36+
return False
37+
return True
38+
39+
1240
@click.group(
1341
help="FastAPI Forge CLI - A tool for generating FastAPI projects.",
1442
context_settings={"help_option_names": ["-h", "--help"]},
@@ -50,6 +78,11 @@ def main(ctx: click.Context, verbose: int) -> None:
5078
),
5179
help="Generate a project using a custom configuration from a YAML file.",
5280
)
81+
@click.option(
82+
"--yes",
83+
is_flag=True,
84+
help="Automatically confirm all prompts (use with caution).",
85+
)
5386
@click.option(
5487
"--conn-string",
5588
help="Generate a project from a PostgreSQL connection string "
@@ -61,10 +94,14 @@ def start(
6194
use_example: bool = False,
6295
no_ui: bool = False,
6396
dry_run: bool = False,
97+
yes: bool = False,
6498
from_yaml: Path | None = None,
6599
conn_string: str | None = None,
66100
) -> None:
67101
"""Start FastAPI Forge."""
102+
if not yes and not confirm_uv_installed():
103+
sys.exit(1)
104+
68105
option_count = sum([use_example, bool(from_yaml), bool(conn_string)])
69106
if option_count > 1:
70107
raise click.UsageError(

0 commit comments

Comments
 (0)