37 lines
783 B
Rust
37 lines
783 B
Rust
mod config;
|
|
use std::str::FromStr;
|
|
mod args;
|
|
mod engine;
|
|
|
|
use crate::logging::logger_init;
|
|
|
|
pub mod error;
|
|
|
|
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
|
|
|