/// Example demonstrating pacman alias functionality
/// 
/// This example shows how pacman aliases automatically resolve
/// to their actual package names during operations.

use libarc::{ArcConfig, Package, PackageManager};

fn main() {
    println!("Pacman Aliases Demo\n");
    println!("===================\n");

    // Create a custom config with aliases
    let mut config = ArcConfig::default();
    
    // Add some common aliases
    config.pacman_aliases.insert("vim-nightly".to_string(), "vim-git".to_string());
    config.pacman_aliases.insert("python3".to_string(), "python".to_string());
    config.pacman_aliases.insert("node".to_string(), "nodejs".to_string());
    
    // Add the actual packages to whitelist
    config.pacman_whitelist = vec![
        "vim-git".to_string(),
        "python".to_string(),
        "nodejs".to_string(),
    ];

    let pm = PackageManager::with_config(config);

    // Demonstrate alias resolution
    println!("Configured aliases:");
    for (alias, actual) in &pm.config().pacman_aliases {
        println!("  {} → {}", alias, actual);
    }
    println!();

    // Show how aliases are resolved
    let test_names = vec!["vim-nightly", "python3", "node", "firefox"];
    
    println!("Alias resolution:");
    for name in test_names {
        let resolved = pm.config().resolve_pacman_alias(name);
        if resolved != name {
            println!("  {} → {} (alias resolved)", name, resolved);
        } else {
            println!("  {} → {} (no alias)", name, resolved);
        }
    }
    println!();

    // Demonstrate that aliases work in package operations
    println!("Package operations with aliases:");
    
    let pkg_with_alias = Package::Pacman("vim-nightly".to_string());
    println!("  Created package: {:?}", pkg_with_alias);
    println!("  When installing this package, 'vim-git' will actually be installed");
    
    // Note: We can't actually install without root privileges,
    // but the alias resolution happens automatically in install()
    
    println!("\nNote: The library automatically resolves aliases for:");
    println!("  - install()");
    println!("  - uninstall()");
    println!("  - is_installed()");
    println!("  - search()");
}
