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_available_settings()

List all available configuration settings with descriptions and examples.

Source code in src/appimage_updater/config/command.py
def list_available_settings() -> None:
    """List all available configuration settings with descriptions and examples."""
    # Check if we have an output formatter (for JSON/HTML output)
    formatter = get_output_formatter()

    if formatter:
        # For structured formats, provide the data in a structured way
        _list_settings_structured(formatter)
    else:
        # For console formats, use the rich formatting
        _list_settings_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  # Error already handled

        _print_effective_config_header(app_name)
        _print_main_config_table(effective_config)
        _print_checksum_config_table(effective_config)

    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

        _print_config_header()
        _print_basic_settings_table(config.global_config)
        _print_defaults_settings_table(defaults)

    except ConfigLoadError as e:
        _handle_config_load_error(e)