From 2f581abe65eac6d77cbbd40490cc0bbc6e4b6bb3 Mon Sep 17 00:00:00 2001 From: endernon Date: Sun, 29 Dec 2024 19:59:39 +0000 Subject: [PATCH] make config path optional yep --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index ffdffea..bb4044f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ use reqwest::Url; struct Args { /// Path for config path #[arg(short, long)] - config: String, + config: Option, /// Enable debug mode #[arg(long, default_value_t = false)] @@ -80,8 +80,10 @@ fn main() { } }; - if let Err(e) = cook(args, executable_path, debug_mode) { - println!("{}", e); + if let Some(T) = &args.config { + if let Err(e) = cook(args, executable_path, debug_mode) { + println!("{}", e); + } } } @@ -91,7 +93,7 @@ fn cook(args: Args, executable_path: &str, mut debug_mode: bool) -> Result<(), E // load configs let json_config: Jsonconfig = - serde_json::from_reader(fs::File::open(config).map_err(|_| Errorfr::ItemJsonMissing)?) + serde_json::from_reader(fs::File::open(config.unwrap()).map_err(|_| Errorfr::ItemJsonMissing)?) .map_err(Errorfr::ItemJsonCorrupt)?; let idsmap: HashMap = serde_json::from_reader( fs::File::open(executable_path.to_owned() + "/id_keys.json")