updated example use in main

This commit is contained in:
2026-02-28 20:19:53 +01:00
parent 984246b263
commit b1c7d96f29

View File

@@ -5,7 +5,9 @@ use std::{
};
use crate::{
conflict_resolver::ConflictSolver,
fomod::{FileType, FileTypeEnum},
linker::Linker,
mod_config_installer::FomodInstaller,
};
@@ -95,14 +97,43 @@ struct Mod {
fn main() -> Result<(), Box<dyn Error>> {
const XML_PATH: &str = "./data/xml/ineed.xml";
let xml = fs::read_to_string(XML_PATH)?;
let loaded_mod = Mod {
name: "INeed".to_owned(),
source: Path::new("./data/mods/iNeed v1").to_owned(),
priority: 0,
};
let config: fomod::Config = quick_xml::de::from_str(&xml)?;
let installer = FomodInstaller::new(config, vec![], install_prompt::prompt);
dbg!(installer.run());
let files = installer.run();
let converted_files: Vec<_> = files
.iter()
.flat_map(|f| ModFile::from_installer(f.clone(), &loaded_mod).unwrap())
.collect();
let mut solver = ConflictSolver::new();
for file in &converted_files {
if let Some(conflict) = solver.add_file(file, &loaded_mod) {
println!("Conflict deteced: {:?}", conflict);
return Ok(());
}
}
let files_to_link = solver.export_files();
let linker = Linker::new(Path::new("./data/target"), Path::new("./data/install"));
linker.link_install_to_target()?;
for (file, from_mod) in files_to_link {
linker.link_mod_file(file, from_mod)?;
}
Ok(())
}