diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-03-14 15:44:49 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-03-14 15:47:16 +0100 |
commit | 4d3534b027c3c53b2bdf882f9618cb1f0c91d994 (patch) | |
tree | f65ba55f9416e68cec1d6352783c1e87d49e65b7 | |
parent | 9f043d537051266396c8dfdc86895014605e3b4a (diff) |
tool: Add option to set the kind of armored data.
-rw-r--r-- | tool/src/sq-usage.rs | 2 | ||||
-rw-r--r-- | tool/src/sq.rs | 11 | ||||
-rw-r--r-- | tool/src/sq_cli.rs | 10 |
3 files changed, 20 insertions, 3 deletions
diff --git a/tool/src/sq-usage.rs b/tool/src/sq-usage.rs index ddf4f741..a68a9b9f 100644 --- a/tool/src/sq-usage.rs +++ b/tool/src/sq-usage.rs @@ -394,6 +394,8 @@ //! -V, --version Prints version information //! //! OPTIONS: +//! --kind <KIND> Selects the kind of header line to produce [default: file] [possible values: message, +//! publickey, secretkey, signature, file] //! -o, --output <FILE> Sets the output file to use //! //! ARGS: diff --git a/tool/src/sq.rs b/tool/src/sq.rs index 7fa375d9..582da3c6 100644 --- a/tool/src/sq.rs +++ b/tool/src/sq.rs @@ -189,8 +189,15 @@ fn real_main() -> Result<(), failure::Error> { ("enarmor", Some(m)) => { let mut input = open_or_stdin(m.value_of("input"))?; let mut output = create_or_stdout(m.value_of("output"), force)?; - let mut filter = armor::Writer::new(&mut output, armor::Kind::File, - &[])?; + let kind = match m.value_of("kind").expect("has default value") { + "message" => armor::Kind::Message, + "publickey" => armor::Kind::PublicKey, + "secretkey" => armor::Kind::SecretKey, + "signature" => armor::Kind::Signature, + "file" => armor::Kind::File, + _ => unreachable!(), + }; + let mut filter = armor::Writer::new(&mut output, kind, &[])?; io::copy(&mut input, &mut filter)?; }, ("dearmor", Some(m)) => { diff --git a/tool/src/sq_cli.rs b/tool/src/sq_cli.rs index 0180369f..619fcd03 100644 --- a/tool/src/sq_cli.rs +++ b/tool/src/sq_cli.rs @@ -181,7 +181,15 @@ pub fn build() -> App<'static, 'static> { .arg(Arg::with_name("output").value_name("FILE") .long("output") .short("o") - .help("Sets the output file to use"))) + .help("Sets the output file to use")) + .arg(Arg::with_name("kind") + .value_name("KIND") + .long("kind") + .possible_values(&["message", "publickey", "secretkey", + "signature", "file"]) + .default_value("file") + .help("Selects the kind of header line to produce"))) + .subcommand(SubCommand::with_name("dearmor") .about("Removes ASCII Armor from a file") .arg(Arg::with_name("input").value_name("FILE") |