// Workspace: weaponry // File: examples/usage_scenario.rs //! Test use case of a scenario //! //! use clap::Parser; use std::path::Path; use weaponry::interfaces::ToAnalysis; // TODO : All of these should likely be in the prelude if used like this use weaponry::weaponry_structs::CrossRecipeScenario; use weaponry::weaponry_structs::equipement_scenario::ConfigEquipementScenario; use weaponry::{ interfaces::{Reportable, Scenario, ToCSV}, weaponry_structs::RefinedEquipementList, }; // use weaponry::interfaces:: fn main() { let args = CLIArgs::parse(); let save_path = args.path.unwrap_or("data/first_data".into()); let scenarios = CrossRecipeScenario::new_with_config(ConfigEquipementScenario { table_name: "Equipements".into(), db_path: "./databases/weapons.db".into(), shape: args.shapes.then_some(()), materials: args.materials, nature: args.natures.then_some(()), finishing: args.finishing.then_some(()), }) .unwrap(); let refined_list = scenarios.generate_refined_recipes().unwrap(); // if args.html_export{} refined_list.write_html(&save_path).unwrap(); // if args.csv_export{} // export_as_csv(&refined_list, save_path); } #[derive(Parser, Debug)] /// Basic cli pub struct CLIArgs { /// The path to save to. pub path: Option, /// Wether to generate shapes #[arg(short, long, default_value_t = true)] pub shapes: bool, /// Wether to generate materials #[arg(short, long)] pub materials: Option, /// Wether to generate all natures #[arg(short, long, default_value_t = true)] pub natures: bool, /// Wether to generate all finishing #[arg(short, long, default_value_t = false)] pub finishing: bool, } #[allow(dead_code)] fn export_as_csv(refined_list: &RefinedEquipementList, save_path: &str) { println!("{}", refined_list.get_report(Some("Refined List"))); println!( "Saved initial data as {}.html: {:?}", save_path, refined_list.write_csv(Path::new(&format!("{save_path}.csv"))) ); }