1 use std::{fs::File, io}; 2 3 use app::Application; 4 use clap::Parser; 5 use config::{appconfig::DeserializeAppOption, cmd::CmdConfig}; 6 use utils::log_util::Log; 7 8 mod app; 9 mod config; 10 mod utils; 11 12 #[macro_use] 13 extern crate log; 14 extern crate simplelog; 15 16 fn main() -> io::Result<()> { 17 let config = CmdConfig::parse(); 18 Log::init(config.level)?; 19 20 let setting; 21 22 let file = File::open("config.yam"); 23 if file.is_err() { 24 setting = DeserializeAppOption::default(); 25 } else { 26 setting = serde_yaml::from_reader::<File, DeserializeAppOption>(file?).unwrap_or_default(); 27 } 28 29 Application::new(config.file, setting.to_app_setting())?.run() 30 } 31