summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-04-11 15:43:08 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-04-12 12:41:51 +0200
commit017536c5f0e2f9e584175a402583c7a0623c6ab3 (patch)
treee48209d8271b973c3c4e63d97acd8056bc056f73 /tool
parentb8742923d134c5c3a91a2521556ecba2085cece7 (diff)
tool: Indent based on the terminal size.
Diffstat (limited to 'tool')
-rw-r--r--tool/Cargo.toml1
-rw-r--r--tool/src/commands/decrypt.rs5
-rw-r--r--tool/src/commands/dump.rs5
3 files changed, 9 insertions, 2 deletions
diff --git a/tool/Cargo.toml b/tool/Cargo.toml
index c6644ff2..517df1ca 100644
--- a/tool/Cargo.toml
+++ b/tool/Cargo.toml
@@ -30,6 +30,7 @@ failure = "0.1.2"
prettytable-rs = "0.8.0"
rpassword = "3.0"
tempfile = "3.0.4"
+termsize = "0.1"
time = "0.1.38"
[build-dependencies]
diff --git a/tool/src/commands/decrypt.rs b/tool/src/commands/decrypt.rs
index 0b7e33f7..4d000cc3 100644
--- a/tool/src/commands/decrypt.rs
+++ b/tool/src/commands/decrypt.rs
@@ -2,6 +2,7 @@ use failure::{self, ResultExt};
use std::collections::HashMap;
use std::io;
use rpassword;
+extern crate termsize;
extern crate sequoia_openpgp as openpgp;
use sequoia_core::Context;
@@ -77,7 +78,9 @@ impl<'a> Helper<'a> {
key_hints: hints,
dump_session_key: dump_session_key,
dumper: if dump || hex {
- Some(PacketDumper::new(80, false))
+ let width =
+ termsize::get().map(|s| s.cols as usize).unwrap_or(80);
+ Some(PacketDumper::new(width, false))
} else {
None
},
diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs
index d5c5725f..96f01e5a 100644
--- a/tool/src/commands/dump.rs
+++ b/tool/src/commands/dump.rs
@@ -1,6 +1,8 @@
use std::io::{self, Read};
use time;
+extern crate termsize;
+
extern crate sequoia_openpgp as openpgp;
use openpgp::constants::SymmetricAlgorithm;
use openpgp::conversions::hex;
@@ -19,7 +21,8 @@ pub fn dump(input: &mut io::Read, output: &mut io::Write, mpis: bool, hex: bool,
let mut ppr
= openpgp::parse::PacketParserBuilder::from_reader(input)?
.map(hex).finalize()?;
- let mut dumper = PacketDumper::new(80, mpis);
+ let width = termsize::get().map(|s| s.cols as usize).unwrap_or(80);
+ let mut dumper = PacketDumper::new(width, mpis);
while let PacketParserResult::Some(mut pp) = ppr {
let additional_fields = match pp.packet {