added get_instance_config in rootConfig
This commit is contained in:
@@ -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<ModdedInstance, Box<dyn Error>> {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user