summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2022-06-07 16:43:46 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2022-06-08 14:49:43 +0200
commit5fe81786e2059c03ee2bf9aaddd70560655b9c53 (patch)
treea854c7cc626eee3b847023375a1f6a03553ab45c
parent0f0ec30036622cdd027237a9ffab11aa601d2d8c (diff)
sq: Derive inspect subcommand.
- This is part of the effort of moving to clap3's derive API and profit from the added type safety.
-rw-r--r--sq/src/sq_cli.rs80
1 files changed, 45 insertions, 35 deletions
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<String>,
}
+#[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<String>,
+ #[clap(
+ long = "certifications",
+ help = "Prints third-party certifications",
+ )]
+ pub certifications: bool,
+
+}
+
#[cfg(feature = "autocrypt")]
pub mod autocrypt {
use super::*;