From 202ed4fcaa69e7de23e83fab0bae4ced6209eee4 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 2 May 2023 20:37:23 +0200 Subject: added config option for default mc version changed version input system --- src/main.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 82c0ade..93da718 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use modlist::{ config::Cfg, db::{config_get_current_list, lists_get, lists_get_all_ids}, download, export, get_current_list, import, list_add, list_change, list_remove, list_version, - mod_add, mod_remove, update, IDSelector, List, Modloader, + mod_add, mod_remove, update, IDSelector, List, Modloader, check_game_versions, VersionLevel, }; //TODO implement remote sql db @@ -18,6 +18,10 @@ struct Cli { /// config file path #[arg(short, long)] config: Option, + + /// Force GameVersion update + #[arg(long)] + force_gameupdate: bool, } #[derive(Subcommand)] @@ -72,6 +76,7 @@ enum Commands { /// the list you want to export list: Option, }, + Test } #[derive(Subcommand)] @@ -147,7 +152,8 @@ enum ListCommands { async fn main() { let cli = Cli::parse(); - let config = Cfg::init(cli.config).unwrap(); + let config = Cfg::init(cli.config).await.unwrap(); + check_game_versions(format!("{}/versions.json", config.versions).as_str(), cli.force_gameupdate).await.unwrap(); match cli.command { Commands::Mod { command } => { @@ -204,11 +210,10 @@ async fn main() { None => config.clone().defaults.modloader, }; + let versions_path = &config.versions; let ver = match version { - Some(ver) => ver, - //TODO get latest version - //TODO impl config for specific version or latest or latest snap - None => "1.19.4".to_string(), + Some(ver) => VersionLevel::from(&ver).get(versions_path).unwrap(), + None => config.clone().defaults.version.get(versions_path).unwrap(), }; list_add(config, id, ver, ml, directory) @@ -262,6 +267,7 @@ async fn main() { import(config, filestr, download).await } Commands::Export { list } => export(config, list), + Commands::Test => Ok(()), } .unwrap(); } -- cgit v1.2.3