use std::io::Write;
use clap::{Args, Subcommand};
mod enroll;
mod init;
mod list;
mod show;
mod use_ssh;
use enroll::EnrollArgs;
use init::InitArgs;
use list::ListArgs;
use show::ShowArgs;
use use_ssh::UseSshArgs;
#[derive(Debug, Args)]
pub(super) struct KeyArgs {
#[command(subcommand)]
command: KeyCommand,
}
#[derive(Debug, Subcommand)]
enum KeyCommand {
Init(InitArgs),
List(ListArgs),
Show(ShowArgs),
UseSsh(UseSshArgs),
Enroll(EnrollArgs),
}
pub(super) fn run(args: KeyArgs, stdout: &mut dyn Write) -> Result<(), Box<dyn std::error::Error>> {
match args.command {
KeyCommand::Init(args) => {
tracing::debug!(command = "key.init", "command_start");
init::run(args, stdout)
}
KeyCommand::List(args) => {
tracing::debug!(command = "key.list", "command_start");
list::run(args, stdout)
}
KeyCommand::Show(args) => {
tracing::debug!(command = "key.show", "command_start");
show::run(args, stdout)
}
KeyCommand::UseSsh(args) => {
tracing::debug!(command = "key.use-ssh", "command_start");
use_ssh::run(args, stdout)
}
KeyCommand::Enroll(args) => {
tracing::debug!(command = "key.enroll", "command_start");
enroll::run(args, stdout)
}
}
}