From 2263f1e14a671c93aa045b5649befbf250712020 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 2 Mar 2025 22:13:19 +0100 Subject: implement test if config file exists, otherwise creation of default file will be offered --- src/main.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 302ba7a..b218f9b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,16 +45,20 @@ async fn main() -> Result<()> { std::process::exit(0); } - // Build default config - // let mut cfg = BibiConfig::default(); + if parsed_args + .cfg_path + .as_ref() + .is_some_and(|f| !f.try_exists().unwrap() || !f.is_file()) + { + BibiConfig::create_default_config(&parsed_args); + } - // if parsed_args.light_theme { - // cfg.light_colors(); - // } - // // Merge values from config file if present - // cfg.parse_config(&parsed_args)?; + let mut cfg = if parsed_args.cfg_path.is_some() { + BibiConfig::parse_config(&parsed_args)? + } else { + BibiConfig::default() + }; - let mut cfg = BibiConfig::parse_config(&parsed_args)?; init_error_hooks()?; // Create an application. -- cgit v1.2.3