aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorlukeflo2025-03-02 22:13:19 +0100
committerlukeflo2025-03-02 22:14:13 +0100
commit2263f1e14a671c93aa045b5649befbf250712020 (patch)
treea653c7723e2c9fc76a5b5290521c211e5a5dfaef /src/main.rs
parent2e1204e98704e466c3b210f05478d0275ea3ea71 (diff)
downloadbibiman-2263f1e14a671c93aa045b5649befbf250712020.tar.gz
bibiman-2263f1e14a671c93aa045b5649befbf250712020.zip
implement test if config file exists, otherwise creation of default file will be offered
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs20
1 files changed, 12 insertions, 8 deletions
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.