Interactive mode utilities for AppImage Updater commands.
This module provides interactive prompts and guidance for commands that take parameters,
making the CLI more user-friendly for new users.
console = Console()
module-attribute
interactive_add_command()
Interactive mode for the add command.
Source code in src/appimage_updater/ui/interactive.py
| def interactive_add_command() -> InteractiveResult:
"""Interactive mode for the add command."""
_display_welcome_message()
try:
# Collect all settings through helper functions
basic_settings = _collect_basic_add_settings()
rotation_settings = _collect_rotation_add_settings(basic_settings["name"])
checksum_settings = _collect_checksum_add_settings()
advanced_settings = _collect_advanced_add_settings(basic_settings["url"])
# Combine all settings
all_settings = {**basic_settings, **rotation_settings, **checksum_settings, **advanced_settings}
# Display summary and confirm
_display_add_summary(all_settings)
if not Confirm.ask("\nAdd this application?", default=True):
console.print("[yellow]Operation cancelled[/yellow]")
return InteractiveResult.cancelled_result("user_cancelled")
return InteractiveResult.success_result(all_settings)
except KeyboardInterrupt:
console.print("\n[yellow]Operation cancelled[/yellow]")
return InteractiveResult.cancelled_result("keyboard_interrupt")
|
interactive_edit_command(app_names)
Interactive mode for the edit command.
Source code in src/appimage_updater/ui/interactive.py
| def interactive_edit_command(app_names: list[str]) -> InteractiveResult:
"""Interactive mode for the edit command."""
console.print(
Panel.fit(
f"[bold cyan]Interactive Edit Mode[/bold cyan]\nLet's edit configuration for: {', '.join(app_names)}",
border_style="cyan",
)
)
try:
# Collect all updates from different sections
updates = {}
updates.update(_collect_basic_edit_settings())
updates.update(_collect_rotation_settings())
updates.update(_collect_checksum_settings())
updates.update(_collect_advanced_settings())
if not updates:
console.print("[yellow]No changes specified[/yellow]")
return InteractiveResult.cancelled_result("no_changes")
# Summary
console.print("\n[bold green]Changes Summary[/bold green]")
for key, value in updates.items():
console.print(f" {key}: {value}")
if not Confirm.ask("\nApply these changes?", default=True):
console.print("[yellow]Operation cancelled[/yellow]")
return InteractiveResult.cancelled_result("user_cancelled")
return InteractiveResult.success_result(updates)
except KeyboardInterrupt:
console.print("\n[yellow]Operation cancelled[/yellow]")
return InteractiveResult.cancelled_result("keyboard_interrupt")
|