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
+107
View File
@@ -0,0 +1,107 @@
use clap::Parser;
use clap::Subcommand;
#[derive(Parser, Debug)]
#[clap(
name = "Husk milter",
about = "Encrypting milter.",
arg_required_else_help = true,
)]
pub struct CliArgs {
#[clap(
long, short,
help = "Configuration file.",
)]
pub config: Option<String>,
#[clap(subcommand)]
pub subcommand: HuskSubcommands,
}
// Subcommands Level 1
#[derive(Debug, Subcommand)]
pub enum HuskSubcommands {
Daemon(DaemonCommand),
Introducer(IntroducerCommand),
Local,
}
// Daemon subcommands
#[derive(Parser, Debug)]
#[clap(
name = "daemon",
about = "Manage milter daemon.",
subcommand_required = true,
arg_required_else_help = true,
disable_colored_help = true,
disable_version_flag = true,
)]
pub struct DaemonCommand {
#[clap(subcommand)]
pub subcommand: DaemonSubcommand,
}
#[derive(Debug, Subcommand)]
pub enum DaemonSubcommand {
Start,
Stop,
Status
}
// Introducer subcommands
#[derive(Parser, Debug)]
#[clap(
name = "introducer",
about = "Manage introducers.",
subcommand_required = true,
arg_required_else_help = true,
disable_colored_help = true,
disable_version_flag = true,
)]
pub struct IntroducerCommand {
#[clap(subcommand)]
pub subcommand: IntroducerSubcommands,
}
#[derive(Debug, Subcommand)]
pub enum IntroducerSubcommands {
Add(IntroducerAddCommand),
Remove(IntroducerRemoveCommand),
List
}
#[derive(Parser, Debug)]
#[clap(
name = "introducer",
about = "Add introducers.",
)]
pub struct IntroducerAddCommand {
#[clap(
long = "cert",
help = "Certificate to declare as introducer."
)]
pub cert: String,
#[clap(
long = "domains",
help = "Domains this certificate introduces.",
required = true,
num_args = 1..,
value_delimiter = ' '
)]
pub domains: Vec<String>,
}
#[derive(Parser, Debug)]
#[clap(
name = "introducer",
about = "Remove introducers.",
)]
pub struct IntroducerRemoveCommand {
#[clap(
long = "cert",
help = "Certificate to be removed as introducer."
)]
pub cert: String,
}