Skip to content

Commit 78608df

Browse files
committed
✨ Add reset command to delete local FastAPI Cloud configuration
1 parent b963a07 commit 78608df

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/fastapi_cloud_cli/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .commands.env import env_app
55
from .commands.login import login
66
from .commands.logout import logout
7+
from .commands.reset import reset
78
from .commands.whoami import whoami
89
from .logging import setup_logging
910
from .utils.sentry import init_sentry
@@ -20,6 +21,7 @@
2021
app.command()(login)
2122
app.command()(logout)
2223
app.command()(whoami)
24+
app.command()(reset)
2325

2426
app.add_typer(env_app, name="env")
2527

src/fastapi_cloud_cli/commands/deploy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,13 @@ def deploy(
586586
"App not found. Make sure you're logged in the correct account."
587587
)
588588

589-
raise typer.Exit(1)
589+
if not app:
590+
toolkit.print_line()
591+
toolkit.print(
592+
"If you deleted this app, you can run [bold]fastapi reset[/] to delete the local configuration.",
593+
tag="tip",
594+
)
595+
raise typer.Exit(1)
590596

591597
logger.debug("Creating archive for deployment")
592598
archive_path = archive(path or Path.cwd()) # noqa: F841
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import logging
2+
import shutil
3+
from pathlib import Path
4+
from typing import Any
5+
6+
import typer
7+
8+
from fastapi_cloud_cli.utils.cli import get_rich_toolkit
9+
10+
logger = logging.getLogger(__name__)
11+
12+
13+
def reset() -> Any:
14+
"""
15+
Reset by deleting the `.fastapicloud` directory.
16+
"""
17+
with get_rich_toolkit(minimal=True) as toolkit:
18+
config_dir = Path.cwd() / ".fastapicloud"
19+
20+
if not config_dir.exists():
21+
toolkit.print("No FastAPI Cloud configuration found in the current directory.")
22+
logger.debug(f"Configuration directory not found: {config_dir}")
23+
raise typer.Exit(1)
24+
25+
shutil.rmtree(config_dir)
26+
toolkit.print("FastAPI Cloud configuration has been reset successfully! 🚀")
27+
logger.debug(f"Deleted configuration directory: {config_dir}")

0 commit comments

Comments
 (0)