summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2019-05-11 15:01:13 +0200
committerNeal H. Walfield <neal@pep.foundation>2019-05-11 15:02:58 +0200
commitdc08ff046153081e6d3cb112c7bafa5465e71462 (patch)
treefe306b2858bdb74b6a738916f83313b56a00f884 /tool
parent9a1fc50febb843969f2e598f5f103fd269e54bbc (diff)
tool: Make sq inspect fail more verbosely
- If sq inspect doesn't recognize the packet sequence, then have it print the parse errors.
Diffstat (limited to 'tool')
-rw-r--r--tool/src/commands/inspect.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/tool/src/commands/inspect.rs b/tool/src/commands/inspect.rs
index 8f9b776b..6578dfed 100644
--- a/tool/src/commands/inspect.rs
+++ b/tool/src/commands/inspect.rs
@@ -72,7 +72,11 @@ pub fn inspect(m: &clap::ArgMatches, output: &mut io::Write)
}
if let PacketParserResult::EOF(eof) = ppr {
- if eof.is_message().is_ok() {
+ let is_message = eof.is_message();
+ let is_tpk = eof.is_tpk();
+ let is_keyring = eof.is_keyring();
+
+ if is_message.is_ok() {
writeln!(output, "{}OpenPGP Message.",
match (encrypted, ! sigs.is_empty()) {
(false, false) => "",
@@ -94,7 +98,7 @@ pub fn inspect(m: &clap::ArgMatches, output: &mut io::Write)
if literal_prefix.len() == 40 { "..." } else { "" })?;
}
- } else if eof.is_tpk().is_ok() || eof.is_keyring().is_ok() {
+ } else if is_tpk.is_ok() || is_keyring.is_ok() {
let pp = openpgp::PacketPile::from(packets);
let tpk = openpgp::TPK::from_packet_pile(pp)?;
inspect_tpk(output, &tpk, print_keygrips, print_certifications)?;
@@ -107,6 +111,9 @@ pub fn inspect(m: &clap::ArgMatches, output: &mut io::Write)
writeln!(output, "No OpenPGP data.")?;
} else {
writeln!(output, "Unknown sequence of OpenPGP packets.")?;
+ writeln!(output, " Message: {}", is_message.unwrap_err())?;
+ writeln!(output, " TPK: {}", is_tpk.unwrap_err())?;
+ writeln!(output, " Keyring: {}", is_keyring.unwrap_err())?;
writeln!(output)?;
writeln!(output, "Hint: Try 'sq packet dump {}'", input_name)?;
}