From 5fe81786e2059c03ee2bf9aaddd70560655b9c53 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Tue, 7 Jun 2022 16:43:46 +0200 Subject: sq: Derive inspect subcommand. - This is part of the effort of moving to clap3's derive API and profit from the added type safety. --- sq/src/sq_cli.rs | 80 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 35 deletions(-) (limited to 'sq') diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs index 5e336a73..6b8602ce 100644 --- a/sq/src/sq_cli.rs +++ b/sq/src/sq_cli.rs @@ -218,40 +218,6 @@ $ sq encrypt --symmetric message.txt "If a certificate has only expired \ encryption-capable subkeys, falls back \ to using the one that expired last")) - ) - - .subcommand(Command::new("inspect") - .display_order(600) - .about("Inspects data, like file(1)") - .long_about( -"Inspects data, like file(1) - -It is often difficult to tell from cursory inspection using cat(1) or -file(1) what kind of OpenPGP one is looking at. This subcommand -inspects the data and provides a meaningful human-readable description -of it. -") - .after_help( -"EXAMPLES: - -# Inspects a certificate -$ sq inspect juliet.pgp - -# Inspects a certificate ring -$ sq inspect certs.pgp - -# Inspects a message -$ sq inspect message.pgp - -# Inspects a detached signature -$ sq inspect message.sig -") - .arg(Arg::new("input") - .value_name("FILE") - .help("Reads from FILE or stdin if omitted")) - .arg(Arg::new("certifications") - .long("certifications") - .help("Prints third-party certifications")) ); let app = if ! feature_autocrypt { @@ -271,7 +237,8 @@ $ sq inspect message.sig .subcommand(PacketCommand::command()) .subcommand(CertifyCommand::command()) .subcommand(KeyringCommand::command()) - .subcommand(KeyCommand::command()); + .subcommand(KeyCommand::command()) + .subcommand(InspectCommand::command()); app } @@ -2369,6 +2336,49 @@ pub struct KeyserverSendCommand { pub input: Option, } +#[derive(Parser, Debug)] +#[clap( + name = "inspect", + display_order(600), + about = "Inspects data, like file(1)", + long_about = +"Inspects data, like file(1) + +It is often difficult to tell from cursory inspection using cat(1) or +file(1) what kind of OpenPGP one is looking at. This subcommand +inspects the data and provides a meaningful human-readable description +of it. +", + after_help = +"EXAMPLES: + +# Inspects a certificate +$ sq inspect juliet.pgp + +# Inspects a certificate ring +$ sq inspect certs.pgp + +# Inspects a message +$ sq inspect message.pgp + +# Inspects a detached signature +$ sq inspect message.sig +", +)] +struct InspectCommand { + #[clap( + value_name = "FILE", + help = "Reads from FILE or stdin if omitted", + )] + pub input: Option, + #[clap( + long = "certifications", + help = "Prints third-party certifications", + )] + pub certifications: bool, + +} + #[cfg(feature = "autocrypt")] pub mod autocrypt { use super::*; -- cgit v1.2.3