diff options
author | Igor Matuszewski <igor@sequoia-pgp.org> | 2019-12-12 03:25:44 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-12-12 14:24:11 +0100 |
commit | 7b0dc8860fa54546304a40b167533edc26eccc73 (patch) | |
tree | c8e1930cab4d0e25b27ab07ddce356386959bfdd /tool | |
parent | aede3b91ebe3e3486171163f7d90c2b7cefbf7bc (diff) |
tool: Prefer crossterm library over termsize.
- This allows us to get rid of another dependency that uses winapi
0.2, the last being mio 0.6 (0.7 is not yet released). In terms
of linkage we still should only link to what we use - no new
Windows API usage introduced here.
Diffstat (limited to 'tool')
-rw-r--r-- | tool/Cargo.toml | 2 | ||||
-rw-r--r-- | tool/src/commands/decrypt.rs | 6 | ||||
-rw-r--r-- | tool/src/sq.rs | 5 |
3 files changed, 7 insertions, 6 deletions
diff --git a/tool/Cargo.toml b/tool/Cargo.toml index 122db61a..66c43583 100644 --- a/tool/Cargo.toml +++ b/tool/Cargo.toml @@ -33,7 +33,7 @@ itertools = "0.8" prettytable-rs = "0.8.0" rpassword = "4.0" tempfile = "3.0.4" -termsize = "0.1" +crossterm = "0.13" tokio-core = "0.1" [build-dependencies] diff --git a/tool/src/commands/decrypt.rs b/tool/src/commands/decrypt.rs index 2e2753f6..4186a9f7 100644 --- a/tool/src/commands/decrypt.rs +++ b/tool/src/commands/decrypt.rs @@ -1,8 +1,8 @@ +use crossterm::terminal; 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; @@ -88,8 +88,8 @@ impl<'a> Helper<'a> { key_hints: hints, dump_session_key: dump_session_key, dumper: if dump || hex { - let width = - termsize::get().map(|s| s.cols as usize).unwrap_or(80); + let width = terminal::size().ok().map(|(cols, _)| cols as usize) + .unwrap_or(80); Some(PacketDumper::new(width, false)) } else { None diff --git a/tool/src/sq.rs b/tool/src/sq.rs index 950ce27a..d0b3420f 100644 --- a/tool/src/sq.rs +++ b/tool/src/sq.rs @@ -7,10 +7,11 @@ extern crate failure; extern crate prettytable; extern crate rpassword; extern crate tempfile; -extern crate termsize; +extern crate crossterm; extern crate itertools; extern crate tokio_core; +use crossterm::terminal; use failure::ResultExt; use prettytable::{Table, Cell, Row}; use std::fs::{File, OpenOptions}; @@ -327,7 +328,7 @@ fn real_main() -> Result<(), failure::Error> { } else { None }; - let width = termsize::get().map(|s| s.cols as usize); + let width = terminal::size().ok().map(|(cols, _)| cols as usize); commands::dump(&mut input, &mut output, m.is_present("mpis"), m.is_present("hex"), session_key.as_ref(), width)?; |