Skip to content

Commit 72d8153

Browse files
committed
Exit rogue after successful update
1 parent e40c601 commit 72d8153

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

rogue/common/update_checker.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import json
99
import shutil
1010
import subprocess # nosec: B404
11+
import sys
1112
from datetime import datetime, timedelta
1213
from typing import Any, Dict, Optional
1314

@@ -170,7 +171,9 @@ def _show_update_prompt(latest_version: str, current_version: str) -> None:
170171
)
171172

172173
if should_update:
173-
run_update_command()
174+
success = run_update_command()
175+
if success:
176+
exit_gracefully()
174177
else:
175178
console.print(
176179
"[dim]Update skipped. Run 'uv tool upgrade rogue-ai' or "
@@ -183,7 +186,7 @@ def _show_update_prompt(latest_version: str, current_version: str) -> None:
183186
console.print()
184187

185188

186-
def run_update_command() -> None:
189+
def run_update_command() -> bool:
187190
"""Execute the appropriate update command based on installation method."""
188191
console = Console()
189192

@@ -200,7 +203,7 @@ def run_update_command() -> None:
200203
"[dim]or[/dim]"
201204
"[dim]- pip install rogue-ai -U[/dim]",
202205
)
203-
return
206+
return False
204207

205208
with console.status("[yellow]Updating rogue-ai...[/yellow]", spinner="dots"):
206209
# First, try to upgrade using uv tool
@@ -232,6 +235,7 @@ def run_update_command() -> None:
232235
"[dim]Restart any running rogue-ai processes to use the "
233236
"new version.[/dim]",
234237
)
238+
return True
235239
else:
236240
console.print("[bold red]❌ Update failed![/bold red]")
237241
if result.stderr:
@@ -255,3 +259,12 @@ def run_update_command() -> None:
255259
"[dim]Please try running 'uv tool upgrade rogue-ai' or "
256260
"'uvx --refresh rogue-ai' manually.[/dim]",
257261
)
262+
return False
263+
264+
265+
def exit_gracefully() -> None:
266+
"""Exit the application gracefully."""
267+
console = Console()
268+
console.print("[bold green]✅ Rogue-ai updated successfully![/bold green]")
269+
console.print("Please rerun `uvx rogue-ai` to use the new version.")
270+
sys.exit(0)

0 commit comments

Comments
 (0)