From 2339c33fb944dfab027c4eeb13db146d5069177b Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Mon, 30 May 2022 16:59:46 +0200 Subject: sq: Derive dearmor 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 | 72 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 33 deletions(-) (limited to 'sq') 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, + #[clap( + short, + long, + value_name = "FILE", + help = "Writes to FILE or stdout if omitted" + )] + pub output: Option, +} -- cgit v1.2.3