Skip to content

Commit 2e0e717

Browse files
committed
✨ Add logout command
1 parent 8c3cf79 commit 2e0e717

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/fastapi_cloud_cli/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .commands.deploy import deploy
44
from .commands.env import env_app
55
from .commands.login import login
6+
from .commands.logout import logout
67
from .commands.whoami import whoami
78

89
app = typer.Typer(rich_markup_mode="rich")
@@ -13,6 +14,7 @@
1314
# Additional commands
1415
app.command()(deploy)
1516
app.command()(login)
17+
app.command()(logout)
1618
app.command()(whoami)
1719

1820
app.add_typer(env_app, name="env")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from src.fastapi_cloud_cli.utils.auth import delete_auth_config
2+
from src.fastapi_cloud_cli.utils.cli import get_rich_toolkit
3+
4+
5+
def logout() -> None:
6+
"""
7+
Logout from FastAPI Cloud. 🚀
8+
"""
9+
with get_rich_toolkit(minimal=True) as toolkit:
10+
delete_auth_config()
11+
12+
toolkit.print("You are now logged out! 🚀")

src/fastapi_cloud_cli/utils/auth.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ def write_auth_config(auth_data: AuthConfig) -> None:
1515
auth_path.write_text(auth_data.model_dump_json(), encoding="utf-8")
1616

1717

18+
def delete_auth_config() -> None:
19+
auth_path = get_auth_path()
20+
21+
if auth_path.exists():
22+
auth_path.unlink()
23+
24+
1825
def read_auth_config() -> Optional[AuthConfig]:
1926
auth_path = get_auth_path()
2027

0 commit comments

Comments
 (0)