mod cli;
mod error;
mod output;
mod spinner;
mod config;
mod pacman;
mod flatpak;
mod package_manager;
mod progress;
mod tui;

use package_manager::PackageManager;

fn main() {
    match PackageManager::new() {
        Ok(pm) => {
            match pm.search("postgresql") {
                Ok(results) => {
                    println!("Found {} results:", results.len());
                    for pkg in results {
                        println!("  {:?}", pkg);
                    }
                }
                Err(e) => println!("Search error: {}", e),
            }
        }
        Err(e) => {
            println!("PM error: {}", e);
            match PackageManager::new() {
                Ok(pm) => {
                    match pm.search("postgresql") {
                        Ok(results) => {
                            println!("Found {} results with default config:", results.len());
                            for pkg in results {
                                println!("  {:?}", pkg);
                            }
                        }
                        Err(e) => println!("Search error: {}", e),
                    }
                }
                Err(e) => println!("Still error: {}", e),
            }
        }
    }
}
