First dispatcher

- Create (sub)command structure.
- First experimental dispatcher to start the daemon.
This commit is contained in:
Malte Meiboom
2026-02-22 12:51:05 +01:00
parent 2d072bf10b
commit c33feb1ee7
14 changed files with 323 additions and 35 deletions
+15 -4
View File
@@ -2,9 +2,15 @@
// Husk milter
//
use std::{env, process};
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;
@@ -15,9 +21,14 @@ use daemon::Daemon;
#[tokio::main]
async fn main() {
let args = CliArgs::parse();
let config_file = env::args().nth(1).expect("config file missing");
let husk_config = match HuskConfig::load(&config_file) {
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);
@@ -31,7 +42,7 @@ async fn main() {
let config_container: HuskConfigContainer = Arc::new(Mutex::new(husk_config));
match Daemon::run(config_container).await {
match commands::dispatch(args, config_container).await {
Ok(_) => {
println!("exiting...");
},