Skip to content

command

appimage_updater.config.command

Configuration management command implementation.

console = Console(no_color=(bool(os.environ.get('NO_COLOR', '')))) module-attribute

logger = logging.getLogger(__name__) module-attribute

list_settings(config_file=None, config_dir=None)

List all available configuration settings with descriptions.

Source code in src/appimage_updater/config/command.py
def list_settings(config_file: Path | None = None, config_dir: Path | None = None) -> None:
    """List all available configuration settings with descriptions."""
    formatter = get_output_formatter()

    if formatter and not hasattr(formatter, "console"):
        # For structured formats (markdown, plain, json, html)
        _list_settings_structured(formatter)
    else:
        # For console formats, use the rich formatting with the formatter's console
        if formatter and hasattr(formatter, "console"):
            _list_settings_console(formatter.console)
        else:
            _list_settings_console(console)

reset_global_config(config_file=None, config_dir=None)

Reset global configuration to defaults.

Returns:

Type Description
bool

True if successful, False if error occurred

Source code in src/appimage_updater/config/command.py
def reset_global_config(config_file: Path | None = None, config_dir: Path | None = None) -> bool:
    """Reset global configuration to defaults.

    Returns:
        True if successful, False if error occurred
    """
    try:
        app_configs = AppConfigs(config_path=config_file or config_dir)
        config = app_configs._config
    except ConfigLoadError:
        console.print("[yellow]No existing configuration found. Nothing to reset.")
        return False

    # Reset to defaults
    config.global_config = GlobalConfig()

    console.print("[green]Configuration saved successfully!")

    # Save the updated configuration
    _save_config(config, config_file, config_dir)
    return True

set_global_config_value(setting, value, config_file=None, config_dir=None)

Set a global configuration value.

Returns:

Type Description
bool

True if the setting was applied successfully, False otherwise.

Source code in src/appimage_updater/config/command.py
def set_global_config_value(
    setting: str,
    value: str,
    config_file: Path | None = None,
    config_dir: Path | None = None,
) -> bool:
    """Set a global configuration value.

    Returns:
        True if the setting was applied successfully, False otherwise.
    """
    try:
        global_manager = GlobalConfigManager(config_file or config_dir)
        config = global_manager._config
    except ConfigLoadError:
        # Create new configuration if none exists
        config = Config()

    # Apply the setting change
    if not _apply_setting_change(config, setting, value):
        return False  # Error already displayed

    # Save the updated configuration
    _save_config(config, config_file, config_dir)
    return True

show_effective_config(app_name, config_file=None, config_dir=None)

Show effective configuration for a specific application.

Source code in src/appimage_updater/config/command.py
def show_effective_config(app_name: str, config_file: Path | None = None, config_dir: Path | None = None) -> None:
    """Show effective configuration for a specific application."""
    try:
        app_configs = AppConfigs(config_path=config_file or config_dir)
        config = app_configs._config
        effective_config = config.get_effective_config_for_app(app_name)

        if effective_config is None:
            _handle_app_not_found(app_name)
            return

        output_formatter = get_output_formatter()

        if output_formatter and not hasattr(output_formatter, "console"):
            _print_effective_config_structured(app_name, effective_config, output_formatter)
        else:
            _print_effective_config_rich(app_name, effective_config, output_formatter)

    except ConfigLoadError as e:
        _handle_config_load_error(e)

show_global_config(config_file=None, config_dir=None)

Show current global configuration.

Source code in src/appimage_updater/config/command.py
def show_global_config(config_file: Path | None = None, config_dir: Path | None = None) -> None:
    """Show current global configuration."""
    try:
        app_configs = AppConfigs(config_path=config_file or config_dir)
        config = app_configs._config
        defaults = config.global_config.defaults
        output_formatter = get_output_formatter()

        if output_formatter and not hasattr(output_formatter, "console"):
            _print_global_config_structured(config.global_config, defaults, output_formatter)
        else:
            _print_global_config_rich(config.global_config, defaults, output_formatter)

    except ConfigLoadError as e:
        _handle_config_load_error(e)