Perfect flag implementation

This commit is contained in:
endernon 2025-01-17 21:26:50 +00:00
parent afa7971f17
commit 3d2d96f86e

View file

@ -47,6 +47,12 @@ fn dl_json(url: Url, savename: String) -> Result<(), Errorfr> {
} }
fn main() { fn main() {
if let Err(e) = main_2() {
println!("{}", e)
}
}
fn main_2() -> Result<(), Errorfr> {
let args = Args::parse(); let args = Args::parse();
let mut executable_path = env::current_exe().unwrap(); let mut executable_path = env::current_exe().unwrap();
PathBuf::pop(&mut executable_path); PathBuf::pop(&mut executable_path);
@ -64,11 +70,38 @@ fn main() {
}; };
// check if files load properly and all that // check if files load properly and all that
let loaded_config: Jsonconfig = {
if let Some(t) = &args.config { if let Some(t) = &args.config {
match load_idkeys(executable_path) { match load_jsonconfig(t) {
Ok(loaded_idkeys) => { Ok(fr) => {
match load_shinystats(executable_path) { Ok(fr)
Ok(loaded_shinystats) => { }
Err(e) => Err(e),
}
}
else {
println!("no config path provided, fallback to empty.");
Ok(
Jsonconfig {
debug: Some(false),
item_type: ItemTypeDeser::Gear,
crafted_type: None,
name: None,
shiny: None,
ids: None,
powders: None,
rerolls: None,
crafted_durability: None,
crafted_requirements: None,
crafted_ids: None,
crafted_damage: None,
}
)
}
}?;
let loaded_idkeys = load_idkeys(executable_path)?;
let loaded_shinystats = load_shinystats(executable_path)?;
// check if perfect status and change name if so. otherwise blank yep // check if perfect status and change name if so. otherwise blank yep
let mut namefr: String = "".to_string(); let mut namefr: String = "".to_string();
@ -76,8 +109,6 @@ fn main() {
namefr = t1 namefr = t1
} }
match load_jsonconfig(t) {
Ok(loaded_config) => {
// debug mode on if in the loaded config // debug mode on if in the loaded config
if let Some(debugconfig) = loaded_config.debug { if let Some(debugconfig) = loaded_config.debug {
if debugconfig { if debugconfig {
@ -100,18 +131,10 @@ fn main() {
println!("{}", e); // print error if there is an error println!("{}", e); // print error if there is an error
} else { } else {
// final string print if there is no error // final string print if there is no error
println!("{}", cooking.unwrap()) println!("{}", cooking?)
}
}
Err(e) => println!("{}", e),
}
}
Err(e) => println!("{}", e),
}
}
Err(e) => println!("{}", e),
}
} }
Ok(())
} }
fn cook(out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>, namefr: String, executable_path: &str) -> Result<String, Errorfr> { fn cook(out: &mut Vec<u8>, debug_mode: &bool, ver: EncodingVersion, json_config: &mut Jsonconfig, idsmap: HashMap<String, u8>, json_shiny: Vec<Shinystruct>, namefr: String, executable_path: &str) -> Result<String, Errorfr> {