Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(subcomponent): Add support for subcomponents #26

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions fixtures/test.log
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
26 changes: 23 additions & 3 deletions src/mod_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct ModComponent {
pub name: String,
pub lang: String,
pub component: String,
pub subcomponent: Option<String>,
}

impl From<String> for ModComponent {
Expand Down Expand Up @@ -48,11 +49,18 @@ impl From<String> 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,
}
}
}
Expand Down Expand Up @@ -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
})
);
}
Expand Down
1 change: 1 addition & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading