From bffc4a6ab82d79714dfcf30d8f2d35327117e0fa Mon Sep 17 00:00:00 2001 From: Vladimir Rubin Date: Mon, 30 Dec 2024 19:41:29 +0200 Subject: [PATCH] fix: check if there are no sources --- src/main.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2cc1ef1..769199a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,16 +49,20 @@ fn main() { filesorters::Config::create(&config_path).unwrap(); } - match filesorters::Config::parse(config_path) { + match filesorters::Config::parse(config_path.clone()) { Ok(parsed_config) => { CONFIG.set(parsed_config).unwrap(); - println!("Config file loaded successfully"); } Err(err) => { - eprintln!("Error: {}", err); + eprintln!("Error reading config: {}", err); process::exit(1); } } + + if cfg!(debug_assertions) { + println!("config:{:#?}", CONFIG.get().unwrap()) + } + { let mut counter = 1; for alias in CONFIG.get().unwrap().sources.keys() { @@ -67,8 +71,12 @@ fn main() { } } - if cfg!(debug_assertions) { - println!("config:{:#?}", CONFIG.get().unwrap()) + if CONFIG.get().unwrap().sources.is_empty() { + println!( + "No sources found, please specify them in {}", + config_path.display() + ); + process::exit(1); } let mut actual_selection: Vec = Vec::new();