saltfish/src/config/mod.rs
fabolous005 ce7866df09
All checks were successful
CI / Saltfish [custom_pieces] (push) Successful in -2m49s
CI / Saltfish (push) Successful in -2m45s
remove nonsense errortypes
2024-04-12 12:18:21 +02:00

35 lines
767 B
Rust

mod config;
use std::str::FromStr;
mod args;
mod engine;
use crate::logging::logger_init;
use self::{args::Args, config::Config};
use clap::Parser;
pub fn get_config() -> Option<Config> {
let args = Args::try_parse().or_else(|err|{
if err.use_stderr() {
println!("{}", err);
return Err(())
}
Ok(Args::default())
});
match args {
Err(_) => None,
Ok(args) => {
let config_path = args.get_config_path().unwrap_or_default();
let config = Config::read(&config_path).merge_args(&args);
logger_init(config.log_file.clone().unwrap(), log::Level::from_str(&config.log_level.clone().unwrap()).unwrap()).unwrap();
Some(config)
}
}
}