Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions rogue/common/update_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import shutil
import subprocess # nosec: B404
import sys
from datetime import datetime, timedelta
from typing import Any, Dict, Optional

Expand Down Expand Up @@ -170,7 +171,9 @@ def _show_update_prompt(latest_version: str, current_version: str) -> None:
)

if should_update:
run_update_command()
success = run_update_command()
if success:
exit_gracefully()
else:
console.print(
"[dim]Update skipped. Run 'uv tool upgrade rogue-ai' or "
Expand All @@ -183,7 +186,7 @@ def _show_update_prompt(latest_version: str, current_version: str) -> None:
console.print()


def run_update_command() -> None:
def run_update_command() -> bool:
"""Execute the appropriate update command based on installation method."""
console = Console()

Expand All @@ -200,7 +203,7 @@ def run_update_command() -> None:
"[dim]or[/dim]"
"[dim]- pip install rogue-ai -U[/dim]",
)
return
return False

with console.status("[yellow]Updating rogue-ai...[/yellow]", spinner="dots"):
# First, try to upgrade using uv tool
Expand Down Expand Up @@ -232,6 +235,7 @@ def run_update_command() -> None:
"[dim]Restart any running rogue-ai processes to use the "
"new version.[/dim]",
)
return True
else:
console.print("[bold red]❌ Update failed![/bold red]")
if result.stderr:
Expand All @@ -255,3 +259,12 @@ def run_update_command() -> None:
"[dim]Please try running 'uv tool upgrade rogue-ai' or "
"'uvx --refresh rogue-ai' manually.[/dim]",
)
return False


def exit_gracefully() -> None:
"""Exit the application gracefully."""
console = Console()
console.print("[bold green]βœ… Rogue-ai updated successfully![/bold green]")
console.print("Please rerun `uvx rogue-ai` to use the new version.")
sys.exit(0)
Loading