Files
husk-milter/src/cli/cli_args.rs
T
Malte Meiboom 4ddc3db6c0 Add creating an introducer from a files
- Introducers can now be created by specifying a file. The certificate
  gets imported and declared as an introducer for the passed domains.
- Add some checks, so that the imported certificate can actually be used
  as an introducer (certificate is alive, not revoked, has certification
  capabilities)
2026-05-13 11:49:40 +02:00

174 lines
3.5 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,
global = true,
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(LocalCommand),
}
// 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: IntroducerSubcommand,
}
#[derive(Debug, Subcommand)]
pub enum IntroducerSubcommand {
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.",
conflicts_with = "cert_file"
)]
pub cert: Option<String>,
#[clap(
long = "cert-file",
help = "Import certificate from CERT_FILE and declare it as introducer.",
value_name = "CERT_FILE",
conflicts_with = "cert"
)]
pub cert_file: Option<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,
#[clap(
long = "demote",
help = "Remove introducing capabilities, but keep certificate authenticated.",
default_value_t = false,
)]
pub demote: bool,
}
// Local subcommands
#[derive(Parser, Debug)]
#[clap(
name = "local",
about = "Manage manually added certificates.",
subcommand_required = true,
arg_required_else_help = true,
disable_colored_help = true,
disable_version_flag = true,
)]
pub struct LocalCommand {
#[clap(subcommand)]
pub subcommand: LocalSubcommand,
}
#[derive(Debug, Subcommand)]
pub enum LocalSubcommand {
Add(LocalAddCommand),
Remove(LocalRemoveCommand),
List
}
#[derive(Parser, Debug)]
#[clap(
name = "local_add",
about = "Add an authenticated certificate.",
)]
pub struct LocalAddCommand {
#[clap(
long = "cert",
help = "Certificate to add."
)]
pub cert_file: String,
}
#[derive(Parser, Debug)]
#[clap(
name = "local_remove",
about = "Certificate to remove.",
)]
pub struct LocalRemoveCommand {
#[clap(
long = "cert",
help = "Certificate to removed."
)]
pub cert: String,
}