diff --git a/fixtures/test.log b/fixtures/test.log index a983acf..6ca8684 100644 --- a/fixtures/test.log +++ b/fixtures/test.log @@ -3,3 +3,4 @@ // ~TP2_File~ #language_number #component_number // [Subcomponent Name -> ] Component Name [ : Version] ~TEST_MOD_NAME_1/TEST.TP2~ #0 #0 // test mod one ~TEST_MOD_NAME_2/TEST.TP2~ #0 #0 // test mod two +~TEST_MOD_NAME_3/TEST.TP2~ #0 #0 diff --git a/src/main.rs b/src/main.rs index b93b686..34f564b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,10 +36,10 @@ fn main() { let number_of_mods_found = mods.len(); let mods_to_be_installed = if args.skip_installed { let installed_mods = parse_weidu_log(installed_log_path); - mods.iter() + mods.into_iter() .filter_map(|weidu_mod| { - if !installed_mods.contains(weidu_mod) { - Some(weidu_mod.clone()) + if !installed_mods.contains(&weidu_mod) { + Some(weidu_mod) } else { None } diff --git a/src/mod_component.rs b/src/mod_component.rs index 4f2c9c0..d9d8df5 100644 --- a/src/mod_component.rs +++ b/src/mod_component.rs @@ -10,6 +10,7 @@ pub struct ModComponent { pub name: String, pub lang: String, pub component: String, + pub subcomponent: Option, } impl From for ModComponent { @@ -48,11 +49,18 @@ impl From for ModComponent { .expect("Could not find component") .replace('#', ""); + lang_and_component.next(); + let subcomponent = lang_and_component + .fuse() + .map(|char| char.to_string()) + .reduce(|acc, e| format!("{} {}", acc, e)); + ModComponent { tp_file, name, lang, component, + subcomponent, } } } @@ -93,16 +101,28 @@ mod tests { tp_file: "TEST.TP2".to_string(), name: "test_mod_name_1".to_string(), lang: "0".to_string(), - component: "0".to_string() + component: "0".to_string(), + subcomponent: Some("test mod one".to_string()) }) ); assert_eq!( - logs.last(), + logs.get(1), Some(&ModComponent { tp_file: "TEST.TP2".to_string(), name: "test_mod_name_2".to_string(), lang: "0".to_string(), - component: "0".to_string() + component: "0".to_string(), + subcomponent: Some("test mod two".to_string()) + }) + ); + assert_eq!( + logs.last(), + Some(&ModComponent { + tp_file: "TEST.TP2".to_string(), + name: "test_mod_name_3".to_string(), + lang: "0".to_string(), + component: "0".to_string(), + subcomponent: None }) ); } diff --git a/src/utils.rs b/src/utils.rs index c621fa1..704199d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -81,6 +81,7 @@ mod tests { name: "test_mod_name_1".to_string(), lang: "0".to_string(), component: "0".to_string(), + subcomponent: None, }; let mod_folder = find_mod_folder(&mod_component, Path::new("fixtures/mods"), 3);