Skip to content

Commit 83a92d2

Browse files
committed
✨ Add logout command
1 parent 8c3cf79 commit 83a92d2

5 files changed

Lines changed: 23 additions & 2 deletions

File tree

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
pytest >=4.4.0,<9.0.0
44
coverage[toml] >=6.2,<8.0
5-
mypy ==1.11.1
5+
mypy ==1.15.0
66
ruff ==0.5.5
77
respx ==0.21.1

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/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from fastapi_cloud_cli import __version__
44
from fastapi_cloud_cli.config import settings
55

6-
from .auth import get_auth_token
6+
from fastapi_cloud_cli.utils.auth import get_auth_token
77

88

99
class APIClient(httpx.Client):

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)