use std::fs::File; use config::CuddleConfig; use simplelog::{ColorChoice, CombinedLogger, Config, TermLogger, TerminalMode, WriteLogger}; mod actions; mod cli; mod config; mod context; mod model; fn main() -> anyhow::Result<()> { init_logging()?; let config = CuddleConfig::from_env()?; let context = context::extract_cuddle(config.clone())?; _ = cli::CuddleCli::new(context)?.execute()?; Ok(()) } fn init_logging() -> anyhow::Result<()> { let mut log_file = dirs::state_dir().ok_or(anyhow::anyhow!("could not find state_dir"))?; log_file.push("cuddle_cli.log"); CombinedLogger::init(vec![ TermLogger::new( log::LevelFilter::Info, Config::default(), TerminalMode::Mixed, ColorChoice::Auto, ), WriteLogger::new( log::LevelFilter::Debug, Config::default(), File::create(log_file).unwrap(), ), ])?; Ok(()) }