summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2022-05-30 16:59:46 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2022-06-08 14:49:43 +0200
commit2339c33fb944dfab027c4eeb13db146d5069177b (patch)
tree791d8fda839924a34d10882343de2641bc26c3f1
parent4944405da8e4e2e4fe924d6d08d400e2f2a7e6b5 (diff)
sq: Derive dearmor 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.rs72
1 files changed, 39 insertions, 33 deletions
diff --git a/sq/src/sq_cli.rs b/sq/src/sq_cli.rs
index b907d6f5..66aa4180 100644
--- a/sq/src/sq_cli.rs
+++ b/sq/src/sq_cli.rs
@@ -369,38 +369,6 @@ signatures, consider using sequoia-sqv.
.help("Verifies signatures with CERT"))
)
- .subcommand(Command::new("dearmor")
- .display_order(510)
- .about("Converts ASCII to binary")
- .long_about(
-"Converts ASCII to binary
-
-To make encrypted data easier to handle and transport, OpenPGP data
-can be transformed to an ASCII representation called ASCII Armor. sq
-transparently handles armored data, but this subcommand can be used to
-explicitly convert existing ASCII-encoded OpenPGP data to its binary
-representation.
-
-The converse operation is \"sq armor\".
-")
- .after_help(
-"EXAMPLES:
-
-# Convert a ASCII certificate to binary
-$ sq dearmor ascii-juliet.pgp
-
-# Convert a ASCII message to binary
-$ sq dearmor ascii-message.pgp
-")
- .arg(Arg::new("input")
- .value_name("FILE")
- .help("Reads from FILE or stdin if omitted"))
- .arg(Arg::new("output")
- .short('o').long("output").value_name("FILE")
- .help("Writes to FILE or stdout if omitted"))
- )
-
-
.subcommand(Command::new("inspect")
.display_order(600)
.about("Inspects data, like file(1)")
@@ -1889,7 +1857,8 @@ $ sq autocrypt encode-sender --prefer-encrypt mutual juliet.pgp
)
)
}
- .subcommand(ArmorCommand::command());
+ .subcommand(ArmorCommand::command())
+ .subcommand(DearmorCommand::command());
app
}
@@ -1942,3 +1911,40 @@ pub struct ArmorCommand {
)]
kind: String,
}
+
+#[derive(Parser, Debug)]
+#[clap(name = "dearmor", display_order(510))]
+#[clap(
+ about = "Converts ASCII to binary",
+ long_about =
+"Converts ASCII to binary
+
+To make encrypted data easier to handle and transport, OpenPGP data
+can be transformed to an ASCII representation called ASCII Armor. sq
+transparently handles armored data, but this subcommand can be used to
+explicitly convert existing ASCII-encoded OpenPGP data to its binary
+representation.
+
+The converse operation is \"sq armor\".
+",
+ after_help =
+"EXAMPLES:
+
+# Convert a ASCII certificate to binary
+$ sq dearmor ascii-juliet.pgp
+
+# Convert a ASCII message to binary
+$ sq dearmor ascii-message.pgp
+",
+ )]
+pub struct DearmorCommand {
+ #[clap(value_name = "FILE", help = "Reads from FILE or stdin if omitted")]
+ pub input: Option<String>,
+ #[clap(
+ short,
+ long,
+ value_name = "FILE",
+ help = "Writes to FILE or stdout if omitted"
+ )]
+ pub output: Option<String>,
+}