File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from .commands .env import env_app
55from .commands .login import login
66from .commands .logout import logout
7+ from .commands .reset import reset
78from .commands .whoami import whoami
89from .logging import setup_logging
910from .utils .sentry import init_sentry
2021app .command ()(login )
2122app .command ()(logout )
2223app .command ()(whoami )
24+ app .command ()(reset )
2325
2426app .add_typer (env_app , name = "env" )
2527
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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 } " )
You can’t perform that action at this time.
0 commit comments