From ff23a11e632812b685f594324e6004c6da81cd4d Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sun, 5 Feb 2023 09:23:29 +0100 Subject: Fixed update shit not correctly updating --- src/input.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index 144f22a..17fc773 100644 --- a/src/input.rs +++ b/src/input.rs @@ -29,6 +29,7 @@ pub enum Cmd { Download, Io, Version, + Setup, } #[derive(Debug, Clone, PartialEq, Eq)] @@ -58,7 +59,7 @@ impl Input { args[0] = args[0].split_at(1).1; let mut command: Option = None; - + let mut mod_options: Option = None; let mut mod_id: Option = None; let mut mod_version: Option = None; @@ -77,7 +78,7 @@ impl Input { let mut file: Option = None; for arg in args { - let arg_split: Vec<&str> = arg.trim().split(" ").collect(); + let arg_split: Vec<&str> = arg.trim().split(' ').collect(); match arg_split[0] { "v" | "version" => { command = Some(Cmd::Version); @@ -97,9 +98,8 @@ impl Input { return Err(MLError::new(ErrorType::ArgumentError, "Please specify a list mod slug or id")); } }, + //TODO impl this "mv" => { - command = Some(Cmd::Mod); - mod_options = Some(ModOptions::Add); if arg_split.len() == 2 { mod_version = Some(String::from(arg_split[1])); } else { @@ -195,6 +195,9 @@ impl Input { "f" => { file = Some(String::from(arg_split[1])); }, + "setup" => { + command = Some(Cmd::Setup); + } _ => return Err(MLError::new(ErrorType::ArgumentError, format!("Unknown Argument ({})", arg_split[0]).as_str())), } } @@ -240,11 +243,12 @@ fn check_mod(mut input: Input, config: Cfg) -> MLE { match input.clone().mod_options.unwrap() { ModOptions::Add => { if input.mod_id.is_none() && input.mod_version.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "No mod id/slug or version id")); }; - if input.list_id.is_none() { input.list = Some(get_current_list(config.clone())?); }; + if input.list_id.is_none() { input.list = Some(get_current_list(config)?); }; Ok(input) }, ModOptions::Remove => { if input.mod_id.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "MODS_NO_MODID")); }; + if input.list_id.is_none() { input.list = Some(get_current_list(config)?); }; Ok(input) }, } @@ -274,7 +278,6 @@ async fn check_list(mut input: Input, config: Cfg) -> MLE { Ok(input) }, ListOptions::Change => { - //TODO check if no change if input.list.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "NO_LIST_SPECIFIED")); }; Ok(input) }, @@ -292,7 +295,7 @@ async fn check_list(mut input: Input, config: Cfg) -> MLE { fn input_from() { let config = Cfg::init("modlist.toml").unwrap(); assert_eq!( - Input::from(config.clone(), vec![String::from("-la test -lv 1.19.3")]).unwrap(), + Input::from(config, vec![String::from("-la test -lv 1.19.3")]).unwrap(), Input { command: Some(Cmd::List), mod_options: None, @@ -310,7 +313,7 @@ fn input_from() { modloader: None, directory: None, io_options: None, - file: None + file: None, } ); -- cgit v1.2.3