use std::{io::Cursor, sync::LazyLock};
use clap::{ArgAction, Parser, Subcommand};
use getset::{CopyGetters, Getters};
use vergen_pretty::{Pretty, vergen_pretty_env};
static LONG_VERSION: LazyLock<String> = LazyLock::new(|| {
let pretty = Pretty::builder().env(vergen_pretty_env!()).build();
let mut cursor = Cursor::new(vec![]);
let mut output = env!("CARGO_PKG_VERSION").to_string();
output.push_str("\n\n");
pretty.display(&mut cursor).unwrap();
output += &String::from_utf8_lossy(cursor.get_ref());
output
});
#[derive(Clone, CopyGetters, Debug, Getters, Parser)]
#[command(author, version, about, long_version = LONG_VERSION.as_str(), long_about = None)]
pub(crate) struct Cli {
#[clap(
short,
long,
action = ArgAction::Count,
help = "Turn up logging verbosity (multiple will turn it up more)",
conflicts_with = "quiet",
)]
#[getset(get_copy = "pub(crate)")]
verbose: u8,
#[clap(
short,
long,
action = ArgAction::Count,
help = "Turn down logging verbosity (multiple will turn it down more)",
conflicts_with = "verbose",
)]
#[getset(get_copy = "pub(crate)")]
quiet: u8,
#[command(subcommand)]
#[getset(get = "pub(crate)")]
command: Commands,
}
#[derive(Clone, Debug, Subcommand)]
pub(crate) enum Commands {
#[clap(about = "Generate a new ed25519 public/private key pair")]
Generate,
#[clap(about = "Verify a public key fingerprint or randomart image")]
Verify {
#[clap(short, long, help = "Verify randomart", default_value_t = false)]
randomart: bool,
#[clap(help = "The signature or randomart to verify")]
signature: String,
},
#[clap(about = "Display the fingerprint of the given public key")]
Fingerprint {
#[clap(help = "The public key file path")]
public_key: String,
},
}