From e68ec35a905d1efef1fd87e205ac8d08536fc53f Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Wed, 1 Jul 2020 09:46:10 +0200 Subject: [PATCH] Move to terminal_size dep after the recent textwrap upgrade --- Cargo.toml | 4 ++-- src/output/help.rs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf568d9e..bc1bd613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,7 @@ strsim = { version = "0.10", optional = true } yaml-rust = { version = "0.4.1", optional = true } atty = { version = "0.2", optional = true } termcolor = { version = "1.1", optional = true } -term_size = { version = "1.0.0-beta1", optional = true } +terminal_size = { version = "0.1.12", optional = true } lazy_static = { version = "1", optional = true } clap_derive = { path = "./clap_derive", version = "3.0.0-beta.1", optional = true } @@ -90,7 +90,7 @@ default = ["suggestions", "color", "derive", "std", "cargo"] std = [] # support for no_std in a backwards-compatible way suggestions = ["strsim"] color = ["atty", "termcolor"] -wrap_help = ["term_size", "textwrap/terminal_size"] +wrap_help = ["terminal_size", "textwrap/terminal_size"] derive = ["clap_derive", "lazy_static"] yaml = ["yaml-rust"] cargo = [] # Disable if you're not using Cargo, enables Cargo-env-var-dependent macros diff --git a/src/output/help.rs b/src/output/help.rs index dbbddd9e..06893736 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -23,11 +23,12 @@ use crate::{ use indexmap::IndexSet; use unicode_width::UnicodeWidthStr; -#[cfg(not(feature = "wrap_help"))] -mod term_size { - pub(crate) fn dimensions() -> Option<(usize, usize)> { - None - } +pub(crate) fn dimensions() -> Option<(usize, usize)> { + #[cfg(not(feature = "wrap_help"))] + return None; + + #[cfg(feature = "wrap_help")] + terminal_size::terminal_size().map(|(w, h)| (w.0.into(), h.0.into())) } fn str_width(s: &str) -> usize { @@ -80,7 +81,7 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> { Some(0) => usize::MAX, Some(w) => w, None => cmp::min( - term_size::dimensions().map_or(100, |(w, _)| w), + dimensions().map_or(100, |(w, _)| w), match parser.app.max_w { None | Some(0) => usize::MAX, Some(mw) => mw,