- Refactor code and move crypto.rs into the common subdirectory. - Fixed comments
50 lines
1.0 KiB
Rust
50 lines
1.0 KiB
Rust
//
|
|
// Husk milter
|
|
//
|
|
|
|
use std::process;
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
use clap::Parser;
|
|
use types::defaults;
|
|
|
|
pub mod cli;
|
|
use cli::cli_args::CliArgs;
|
|
pub mod commands;
|
|
pub mod config;
|
|
use config::{HuskConfig, HuskConfigContainer};
|
|
pub mod types;
|
|
pub mod mail;
|
|
pub mod daemon;
|
|
use daemon::Daemon;
|
|
pub mod common;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let args = CliArgs::parse();
|
|
|
|
let config_file = match &args.config {
|
|
Some(c) => c.as_str(),
|
|
None => defaults::CONFIG_FILE_LOCATION
|
|
};
|
|
|
|
let husk_config = match HuskConfig::load(config_file) {
|
|
Ok(config) => config,
|
|
Err(e) => {
|
|
eprintln!("{:?}", e);
|
|
process::exit(1);
|
|
}
|
|
};
|
|
|
|
log4rs::init_file(husk_config.logfile_config(), Default::default()).unwrap();
|
|
|
|
log::info!("starting...");
|
|
|
|
let config_container: HuskConfigContainer = Arc::new(Mutex::new(husk_config));
|
|
|
|
if let Err(e) = commands::dispatch(args, config_container).await {
|
|
eprintln!("exit with {:?}", e);
|
|
// XXX: actually return an error code
|
|
}
|
|
}
|