diff --git a/src/basic_types.rs b/src/basic_types.rs index 537b781..8f401a9 100644 --- a/src/basic_types.rs +++ b/src/basic_types.rs @@ -1,9 +1,8 @@ -use clap::builder::Str; use serde::{Deserialize, Serialize}; use std::{ error::Error, fs::{self, read_to_string}, - io::{self, Write}, + io::Write, path::{Path, PathBuf}, }; @@ -48,13 +47,15 @@ impl RootConfig { pub fn load_instance_by_id(&self, id: &str) -> Result> { let conf = self - .instances - .iter() - .find(|e| e.id == id) + .get_instance_config(id) .ok_or("ID not found in root config")?; ModdedInstance::load_from_file(&conf.path) } + + pub fn get_instance_config(&self, id: &str) -> Option<&InstancePointer> { + self.instances.iter().find(|e| e.id == id) + } } /// Available game