diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-07-08 18:49:47 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-07-08 18:49:47 +0200 |
commit | c116f1caebb5dcc62de851d65b39b7eb7c90c714 (patch) | |
tree | 1221e1256d2a2503b95df2962061f82b0b6f9a84 /tool | |
parent | 3907b83a624a1265f6617dfdfb95b3422451c91b (diff) |
tool: Hand the target width to the dump function.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/src/commands/dump.rs | 13 | ||||
-rw-r--r-- | tool/src/sq.rs | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/tool/src/commands/dump.rs b/tool/src/commands/dump.rs index 4e3636de..cc279156 100644 --- a/tool/src/commands/dump.rs +++ b/tool/src/commands/dump.rs @@ -1,8 +1,6 @@ use std::io::{self, Read}; use time; -extern crate termsize; - extern crate sequoia_openpgp as openpgp; use openpgp::constants::SymmetricAlgorithm; use openpgp::conversions::hex; @@ -15,13 +13,16 @@ use openpgp::parse::{map::Map, Parse, PacketParserResult}; use super::TIMEFMT; -pub fn dump(input: &mut dyn io::Read, output: &mut dyn io::Write, - mpis: bool, hex: bool, sk: Option<&SessionKey>) - -> Result<()> { +pub fn dump<W>(input: &mut dyn io::Read, output: &mut dyn io::Write, + mpis: bool, hex: bool, sk: Option<&SessionKey>, + width: W) + -> Result<()> + where W: Into<Option<usize>> +{ let mut ppr = openpgp::parse::PacketParserBuilder::from_reader(input)? .map(hex).finalize()?; - let width = termsize::get().map(|s| s.cols as usize).unwrap_or(80); + let width = width.into().unwrap_or(80); let mut dumper = PacketDumper::new(width, mpis); while let PacketParserResult::Some(mut pp) = ppr { diff --git a/tool/src/sq.rs b/tool/src/sq.rs index 02233571..5cbb3223 100644 --- a/tool/src/sq.rs +++ b/tool/src/sq.rs @@ -7,6 +7,7 @@ extern crate failure; extern crate prettytable; extern crate rpassword; extern crate tempfile; +extern crate termsize; extern crate time; extern crate itertools; @@ -272,9 +273,10 @@ fn real_main() -> Result<(), failure::Error> { } else { None }; + let width = termsize::get().map(|s| s.cols as usize); commands::dump(&mut input, &mut output, m.is_present("mpis"), m.is_present("hex"), - session_key.as_ref())?; + session_key.as_ref(), width)?; }, ("split", Some(m)) => { let mut input = open_or_stdin(m.value_of("input"))?; |