mod packagemanager; use packagemanager::{PackageManager, read_default}; mod management; mod config; use config::Config; use std::io; use std::path::PathBuf; fn input() -> Result { let mut val = String::new(); io::stdin().read_line(&mut val)?; Ok(val) } fn main() { let config = Config::new(); let mut ruxconf = std::env::home_dir().unwrap_or_else(|| { PathBuf::new() }); ruxconf.push(".config/rux/rux.conf"); if ruxconf.is_file() { let pac = read_default(ruxconf).unwrap_or_else(|err| { eprintln!("{:?}", err); std::process::exit(1) }); config.run(pac); std::process::exit(0); } let managers = PackageManager::all(); let mut found: bool = false; for prog in managers { if found { break; } if prog.exe.is_file() { println!( "Found {}, is this the manager you want to use? [Y/n]", prog.name ); if input().unwrap().trim().to_lowercase() == "n" { continue; } else { found = true; println!("Would you like to set {} as default? [y/N]", prog.name); if input().unwrap().trim().to_lowercase() == "y" { prog.set_default().unwrap_or_else(|err| { println!( "An error occursed trying to set default {:?}", err.kind() ) }); } config.run(prog); } } } if !found { println!("Sorry, your desired package manager is not supported at this time"); std::process::exit(0); } } fn help() { println!( "COMMANDS: -S Installs a new package -Ss Searches for a package -Sy Updates local cache from repo -Su Upgrades with just your local cache -Syu Upgrades the local cache and then updates the system -R Removes a package from the system -Rdns Purges a package from the system -Sc Clears your local cache -Scc Purges your local cache" ); }