- Create (sub)command structure. - First experimental dispatcher to start the daemon.
108 lines
2.1 KiB
Rust
108 lines
2.1 KiB
Rust
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,
|
|
}
|