mod prompt; mod repository; mod config; mod operations; mod utils; use strum::{EnumIter, IntoEnumIterator}; #[derive(Debug, Clone, EnumIter)] enum MainMenu { Install, Collect, Pull, Diff, Upload, Quit } impl ToString for MainMenu { fn to_string(&self) -> String { match self { MainMenu::Install => "Install files", MainMenu::Collect => "Collect files", MainMenu::Pull => "Pull from git", MainMenu::Diff => "View git diff", MainMenu::Upload => "(Commit) and push to git", MainMenu::Quit => "Exit" }.to_string() } } fn main() { if !repository::open_repo() { println!("Failed to open/clone repo!"); return; } if !std::path::Path::new("repo/mod.toml").exists() { println!("'mod.toml' doesn't exist!"); return; } let mods = match config::parse() { Ok(v) => v, Err(err) => { println!("Failed to process mod.toml!"); println!("{}", err); return; } }; 'main_loop: loop { let res = prompt::select(Some("What do you want to do?"), MainMenu::iter().collect()); match res { MainMenu::Install => operations::install(&mods), MainMenu::Collect => operations::collect(&mods), MainMenu::Pull => repository::pull_repo(), MainMenu::Diff => repository::diff(), MainMenu::Upload => operations::upload(), MainMenu::Quit => break 'main_loop } } }