summaryrefslogtreecommitdiff
path: root/src/input.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-02-05 09:23:29 +0100
committerfxqnlr <[email protected]>2023-02-05 09:23:29 +0100
commitff23a11e632812b685f594324e6004c6da81cd4d (patch)
tree2b503cb25d8ebfbc33d449860e1903a4c6c9513f /src/input.rs
parent2f4b5f1584f88491ea4a6902d69382a0e73aa76d (diff)
downloadmodlist-ff23a11e632812b685f594324e6004c6da81cd4d.tar
modlist-ff23a11e632812b685f594324e6004c6da81cd4d.tar.gz
modlist-ff23a11e632812b685f594324e6004c6da81cd4d.zip
Fixed update shit not correctly updating
Diffstat (limited to 'src/input.rs')
-rw-r--r--src/input.rs19
1 files changed, 11 insertions, 8 deletions
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 {
29 Download, 29 Download,
30 Io, 30 Io,
31 Version, 31 Version,
32 Setup,
32} 33}
33 34
34#[derive(Debug, Clone, PartialEq, Eq)] 35#[derive(Debug, Clone, PartialEq, Eq)]
@@ -58,7 +59,7 @@ impl Input {
58 args[0] = args[0].split_at(1).1; 59 args[0] = args[0].split_at(1).1;
59 60
60 let mut command: Option<Cmd> = None; 61 let mut command: Option<Cmd> = None;
61 62
62 let mut mod_options: Option<ModOptions> = None; 63 let mut mod_options: Option<ModOptions> = None;
63 let mut mod_id: Option<String> = None; 64 let mut mod_id: Option<String> = None;
64 let mut mod_version: Option<String> = None; 65 let mut mod_version: Option<String> = None;
@@ -77,7 +78,7 @@ impl Input {
77 let mut file: Option<String> = None; 78 let mut file: Option<String> = None;
78 79
79 for arg in args { 80 for arg in args {
80 let arg_split: Vec<&str> = arg.trim().split(" ").collect(); 81 let arg_split: Vec<&str> = arg.trim().split(' ').collect();
81 match arg_split[0] { 82 match arg_split[0] {
82 "v" | "version" => { 83 "v" | "version" => {
83 command = Some(Cmd::Version); 84 command = Some(Cmd::Version);
@@ -97,9 +98,8 @@ impl Input {
97 return Err(MLError::new(ErrorType::ArgumentError, "Please specify a list mod slug or id")); 98 return Err(MLError::new(ErrorType::ArgumentError, "Please specify a list mod slug or id"));
98 } 99 }
99 }, 100 },
101 //TODO impl this
100 "mv" => { 102 "mv" => {
101 command = Some(Cmd::Mod);
102 mod_options = Some(ModOptions::Add);
103 if arg_split.len() == 2 { 103 if arg_split.len() == 2 {
104 mod_version = Some(String::from(arg_split[1])); 104 mod_version = Some(String::from(arg_split[1]));
105 } else { 105 } else {
@@ -195,6 +195,9 @@ impl Input {
195 "f" => { 195 "f" => {
196 file = Some(String::from(arg_split[1])); 196 file = Some(String::from(arg_split[1]));
197 }, 197 },
198 "setup" => {
199 command = Some(Cmd::Setup);
200 }
198 _ => return Err(MLError::new(ErrorType::ArgumentError, format!("Unknown Argument ({})", arg_split[0]).as_str())), 201 _ => return Err(MLError::new(ErrorType::ArgumentError, format!("Unknown Argument ({})", arg_split[0]).as_str())),
199 } 202 }
200 } 203 }
@@ -240,11 +243,12 @@ fn check_mod(mut input: Input, config: Cfg) -> MLE<Input> {
240 match input.clone().mod_options.unwrap() { 243 match input.clone().mod_options.unwrap() {
241 ModOptions::Add => { 244 ModOptions::Add => {
242 if input.mod_id.is_none() && input.mod_version.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "No mod id/slug or version id")); }; 245 if input.mod_id.is_none() && input.mod_version.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "No mod id/slug or version id")); };
243 if input.list_id.is_none() { input.list = Some(get_current_list(config.clone())?); }; 246 if input.list_id.is_none() { input.list = Some(get_current_list(config)?); };
244 Ok(input) 247 Ok(input)
245 }, 248 },
246 ModOptions::Remove => { 249 ModOptions::Remove => {
247 if input.mod_id.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "MODS_NO_MODID")); }; 250 if input.mod_id.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "MODS_NO_MODID")); };
251 if input.list_id.is_none() { input.list = Some(get_current_list(config)?); };
248 Ok(input) 252 Ok(input)
249 }, 253 },
250 } 254 }
@@ -274,7 +278,6 @@ async fn check_list(mut input: Input, config: Cfg) -> MLE<Input> {
274 Ok(input) 278 Ok(input)
275 }, 279 },
276 ListOptions::Change => { 280 ListOptions::Change => {
277 //TODO check if no change
278 if input.list.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "NO_LIST_SPECIFIED")); }; 281 if input.list.is_none() { return Err(MLError::new(ErrorType::ArgumentError, "NO_LIST_SPECIFIED")); };
279 Ok(input) 282 Ok(input)
280 }, 283 },
@@ -292,7 +295,7 @@ async fn check_list(mut input: Input, config: Cfg) -> MLE<Input> {
292fn input_from() { 295fn input_from() {
293 let config = Cfg::init("modlist.toml").unwrap(); 296 let config = Cfg::init("modlist.toml").unwrap();
294 assert_eq!( 297 assert_eq!(
295 Input::from(config.clone(), vec![String::from("-la test -lv 1.19.3")]).unwrap(), 298 Input::from(config, vec![String::from("-la test -lv 1.19.3")]).unwrap(),
296 Input { 299 Input {
297 command: Some(Cmd::List), 300 command: Some(Cmd::List),
298 mod_options: None, 301 mod_options: None,
@@ -310,7 +313,7 @@ fn input_from() {
310 modloader: None, 313 modloader: None,
311 directory: None, 314 directory: None,
312 io_options: None, 315 io_options: None,
313 file: None 316 file: None,
314 } 317 }
315 ); 318 );
316 319