#[macro_use] extern crate rust_util; mod fido; mod digest; mod register; mod sign; mod pgp; mod pgpcardutil; mod pgpcardlist; mod pgpcardsign; mod pgpcarddecrypt; mod piv; mod pivsign; mod chall; mod challconfig; use clap::{App, AppSettings, ArgMatches}; use rust_util::util_clap::{CommandError, Command}; pub struct DefaultCommandImpl; impl DefaultCommandImpl { pub fn process_command<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app } pub fn run(_arg_matches: &ArgMatches) -> CommandError { information!("WebAuthn(OpenPGP) cli, use --help for help"); Ok(None) } } fn main() { if let Err(e) = inner_main() { failure_and_exit!("Run cli error: {}", e); } } fn inner_main() -> CommandError { let commands: Vec> = vec![ Box::new(register::CommandImpl), Box::new(sign::CommandImpl), Box::new(pgp::CommandImpl), Box::new(pgpcardlist::CommandImpl), Box::new(pgpcardsign::CommandImpl), Box::new(pgpcarddecrypt::CommandImpl), Box::new(piv::CommandImpl), Box::new(pivsign::CommandImpl), Box::new(chall::CommandImpl), Box::new(challconfig::CommandImpl), ]; let mut app = App::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) .about(env!("CARGO_PKG_DESCRIPTION")) .long_about("Webauthn Cli is a command tool register and sign using FIDO security key") .setting(AppSettings::ColoredHelp); app = DefaultCommandImpl::process_command(app); for command in &commands { app = app.subcommand(command.subcommand()); } let matches = app.get_matches(); for command in &commands { if let Some(sub_cmd_matches) = matches.subcommand_matches(command.name()) { return command.run(&matches, sub_cmd_matches); } } DefaultCommandImpl::run(&matches) }