use clap::{Args, Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(version, about, author, arg_required_else_help = true)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Encrypt(EncryptArgs),
Decrypt(CommonArgs),
}
#[derive(Args, Debug)]
#[command(arg_required_else_help = true)]
pub struct CommonArgs {
#[arg(
short = 'm',
long = "mode",
value_enum,
default_value_t = Mode::ModeGCM,
)]
pub mode: Mode,
#[arg(short = 'i', long = "input")]
pub input: PathBuf,
#[arg(short = 'o', long = "output")]
pub output: PathBuf,
#[arg(short = 'k', long = "key")]
pub key: PathBuf,
}
#[derive(Args, Debug)]
#[command(arg_required_else_help = true)]
pub struct EncryptArgs {
#[command(flatten)]
pub common: CommonArgs,
#[arg(long = "gen-key")]
pub gen_key: bool,
#[arg(
long = "key-size",
value_enum,
default_value_t = KeySize::Bits256,
requires = "gen_key"
)]
pub key_size: KeySize,
#[arg(long = "aad", value_name = "HEX")]
pub aad: Option<String>,
}
#[derive(Copy, Clone, Debug, ValueEnum, Eq, PartialEq)]
pub enum KeySize {
#[value(name = "128")]
Bits128,
#[value(name = "192")]
Bits192,
#[value(name = "256")]
Bits256,
}
#[derive(Copy, Clone, Debug, ValueEnum, Eq, PartialEq)]
pub enum Mode {
#[value(name = "ecb")]
ModeECB,
#[value(name = "ctr")]
ModeCTR,
#[value(name = "gcm")]
ModeGCM,
}