1984a200eSGnoCiYeH use std::{fs::File, io}; 2984a200eSGnoCiYeH 3984a200eSGnoCiYeH use app::Application; 4984a200eSGnoCiYeH use clap::Parser; 5984a200eSGnoCiYeH use config::{appconfig::DeserializeAppOption, cmd::CmdConfig}; 6984a200eSGnoCiYeH use utils::log_util::Log; 7984a200eSGnoCiYeH 8984a200eSGnoCiYeH mod app; 9984a200eSGnoCiYeH mod config; 10984a200eSGnoCiYeH mod utils; 11984a200eSGnoCiYeH 12984a200eSGnoCiYeH #[macro_use] 13984a200eSGnoCiYeH extern crate log; 14984a200eSGnoCiYeH extern crate simplelog; 15984a200eSGnoCiYeH main() -> io::Result<()>16984a200eSGnoCiYeHfn main() -> io::Result<()> { 17984a200eSGnoCiYeH let config = CmdConfig::parse(); 18984a200eSGnoCiYeH Log::init(config.level)?; 19984a200eSGnoCiYeH 20984a200eSGnoCiYeH let setting; 21984a200eSGnoCiYeH 22*f192df42SWeihao Zhu let file = File::open("config.yaml"); 23984a200eSGnoCiYeH if file.is_err() { 24984a200eSGnoCiYeH setting = DeserializeAppOption::default(); 25984a200eSGnoCiYeH } else { 26984a200eSGnoCiYeH setting = serde_yaml::from_reader::<File, DeserializeAppOption>(file?).unwrap_or_default(); 27984a200eSGnoCiYeH } 28984a200eSGnoCiYeH 29984a200eSGnoCiYeH Application::new(config.file, setting.to_app_setting())?.run() 30984a200eSGnoCiYeH } 31