mod detect;
mod keys;
mod setup;
mod test;
pub use self::{detect::DetectCommand, keys::KeysCommand, setup::SetupCommand, test::TestCommand};
use abscissa_core::{Command, Runnable};
use clap::Subcommand;
use std::path::PathBuf;
#[derive(Command, Debug, Runnable, Subcommand)]
pub enum YubihsmCommand {
Detect(DetectCommand),
#[clap(subcommand)]
Keys(KeysCommand),
Setup(SetupCommand),
Test(TestCommand),
}
impl YubihsmCommand {
pub(super) fn config_path(&self) -> Option<&PathBuf> {
crate::yubihsm::mark_cli_command();
match self {
YubihsmCommand::Keys(keys) => keys.config_path(),
YubihsmCommand::Setup(setup) => setup.config.as_ref(),
YubihsmCommand::Test(test) => test.config.as_ref(),
_ => None,
}
}
pub(super) fn verbose(&self) -> bool {
match self {
YubihsmCommand::Detect(detect) => detect.verbose,
YubihsmCommand::Setup(setup) => setup.verbose,
YubihsmCommand::Test(test) => test.verbose,
_ => false,
}
}
}