Skip to content

Commit b449f3b

Browse files
committed
feat(cli): add /update command and startup version check integration
1 parent 947d91f commit b449f3b

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

shello_cli/cli.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,24 @@ def chat(debug, new, yolo):
238238
# Display welcome banner (pass None for user_info since we don't have GitLab user)
239239
print_welcome_banner(None, getattr(version_module, '__version__', '0.1.0'))
240240

241+
# Check for updates on startup (if enabled)
242+
user_settings = settings_manager.load_user_settings()
243+
244+
if user_settings.update_config and user_settings.update_config.check_on_startup:
245+
from shello_cli.update.update_manager import UpdateManager
246+
update_manager = UpdateManager()
247+
248+
# Non-blocking check with timeout
249+
check_result = update_manager.check_for_updates_async(timeout=2.0)
250+
251+
if check_result and check_result.update_available:
252+
console.print(
253+
f"\n💡 [cyan]Update available:[/cyan] "
254+
f"[dim]{check_result.current_version}[/dim] → "
255+
f"[bold]{check_result.latest_version}[/bold]"
256+
)
257+
console.print(" Run [bold]/update[/bold] to upgrade\n")
258+
241259
# Main chat loop
242260
while True:
243261
try:
@@ -291,6 +309,38 @@ def chat(debug, new, yolo):
291309
display_about(getattr(version_module, '__version__', '0.1.0'))
292310
continue
293311

312+
elif user_input.lower().startswith("/update"):
313+
# Handle update command
314+
from shello_cli.update.update_manager import UpdateManager
315+
316+
# Parse optional --force flag
317+
force = "--force" in user_input.lower()
318+
319+
# Create UpdateManager instance
320+
update_manager = UpdateManager()
321+
322+
# Perform update
323+
console.print() # Add spacing before update output
324+
result = update_manager.perform_update(force=force)
325+
326+
# Display result
327+
if result.success:
328+
console.print(f"✓ [green]{result.message}[/green]")
329+
330+
# Only show "Updated to version" and restart message if an actual update occurred
331+
# (not when already on latest version)
332+
if result.new_version and "already on the latest version" not in result.message.lower():
333+
console.print(f" Updated to version [cyan]{result.new_version}[/cyan]")
334+
console.print("\n⚠️ [yellow]Please restart Shello CLI to use the new version.[/yellow]\n")
335+
else:
336+
console.print() # Just add spacing
337+
else:
338+
console.print(f"✗ [red]{result.message}[/red]")
339+
if result.error:
340+
console.print(f" Error: {result.error}\n")
341+
342+
continue
343+
294344
# Skip empty input
295345
if not user_input.strip():
296346
continue

0 commit comments

Comments
 (0)