Skip to content

remove_handler

appimage_updater.cli.handlers.remove_handler

Remove command handler for CLI.

RemoveCommandHandler()

Handler for the remove command.

Source code in src/appimage_updater/cli/handlers/remove_handler.py
def __init__(self) -> None:
    """Initialize the remove command handler."""
    self.console = Console()

console = Console() instance-attribute

get_command_name()

Get the name of this command.

Source code in src/appimage_updater/cli/handlers/remove_handler.py
def get_command_name(self) -> str:
    """Get the name of this command."""
    return "remove"

register_command(app)

Register the remove command with the Typer application.

Source code in src/appimage_updater/cli/handlers/remove_handler.py
def register_command(self, app: typer.Typer) -> None:
    """Register the remove command with the Typer application."""

    @app.command()
    def remove(
        app_names: list[str] | None = CLIOptions.REMOVE_APP_NAME_ARGUMENT_OPTIONAL,
        config_dir: Path | None = CLIOptions.CONFIG_DIR_OPTION,
        yes: bool = CLIOptions.REMOVE_YES_OPTION,
        no: bool = CLIOptions.REMOVE_NO_OPTION,
        debug: bool = CLIOptions.debug_option(),
        output_format: OutputFormat = CLIOptions.FORMAT_OPTION,
        _version: bool = CLIOptions.version_option(self._version_callback),
    ) -> None:
        """Remove applications from the configuration."""
        if app_names is None:
            self._show_remove_help()
            raise typer.Exit(0)

        self._execute_remove_command(
            app_names=app_names,
            config_dir=config_dir,
            yes=yes,
            no=no,
            debug=debug,
            output_format=output_format,
        )

validate_options(**kwargs)

Validate remove command options.

Source code in src/appimage_updater/cli/handlers/remove_handler.py
def validate_options(self, **kwargs: Any) -> None:
    """Validate remove command options."""
    yes = kwargs.get("yes", False)
    no = kwargs.get("no", False)

    if yes and no:
        self.console.print("[red]Error: --yes and --no options are mutually exclusive")
        raise typer.Exit(1)