better error handling in main

This commit is contained in:
Djairo Hougee 2023-05-09 17:50:02 +02:00
parent cf69ad0c19
commit bdfdfa61cd
1 changed files with 28 additions and 26 deletions

View File

@ -1,6 +1,6 @@
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread::{self};
use std::thread;
use clap::Parser;
use mpris::PlayerFinder;
use structs::cli::Cli;
@ -29,15 +29,14 @@ fn default_loop(pf: &PlayerFinder, cfg: &Config, data: &mut Data) {
}
fn main() {
//dotenvy::dotenv().expect("Failed to read .env file");
std::env::set_var("RUST_LOG", "error");
if let Err(e) = env_logger::init() {
panic!("{}", e);
}
let cli = Cli::parse();
let mut cfg: Config = confy::load("polybar-now-playing", cli.config_file.as_str()).unwrap(); //TODO: error handling
cfg.priorities_to_lower();
match confy::load::<Config>("polybar-now-playing", cli.config_file.as_str()) {
Ok(cfg) => {
let mut data: Data = Data::default();
let term = Arc::new(AtomicBool::new(false));
@ -60,4 +59,7 @@ fn main() {
term.swap(false, Ordering::Relaxed);
};
}
},
Err(_) => println!("Failed to read config file {}", cli.config_file),
};
}