chore: allows wrapping help on windows

This commit is contained in:
Kevin K 2016-08-24 22:04:19 -04:00
parent 84ad746ee5
commit 57690b2af1
4 changed files with 7 additions and 16 deletions

View file

@ -19,8 +19,8 @@ ansi_term = { version = "~0.8.0", optional = true }
strsim = { version = "~0.5.1", optional = true } strsim = { version = "~0.5.1", optional = true }
yaml-rust = { version = "~0.3.2", optional = true } yaml-rust = { version = "~0.3.2", optional = true }
clippy = { version = "~0.0.79", optional = true } clippy = { version = "~0.0.79", optional = true }
unicode-width = { version = "~0.1.3", optional = true } unicode-width = "~0.1.3"
unicode-segmentation = { version = "~0.1.2", optional = true } unicode-segmentation = "~0.1.2"
term_size = { version = "~0.1.0", optional = true } term_size = { version = "~0.1.0", optional = true }
[dev-dependencies] [dev-dependencies]
@ -31,7 +31,7 @@ default = ["suggestions", "color", "wrap_help"]
suggestions = ["strsim"] suggestions = ["strsim"]
color = ["ansi_term", "libc"] color = ["ansi_term", "libc"]
yaml = ["yaml-rust"] yaml = ["yaml-rust"]
wrap_help = ["libc", "unicode-width", "term_size", "unicode-segmentation"] wrap_help = ["libc", "term_size"]
lints = ["clippy", "nightly"] lints = ["clippy", "nightly"]
nightly = [] # for building with nightly and unstable features nightly = [] # for building with nightly and unstable features
unstable = [] # for building with unstable features on stable Rust unstable = [] # for building with unstable features on stable Rust

View file

@ -65,9 +65,9 @@ Here's the highlights for v2.10.0
Here's the highlights for v2.9.3 Here's the highlights for v2.9.3
* Adds the ability to generate completions to an `io::Write` object * Adds the ability to generate completions to an `io::Write` object
* Adds an `App::unset_setting` and `App::unset_settings` * Adds an `App::unset_setting` and `App::unset_settings`
* Fixes bug where only first arg in list of `required_unless_one` is recognized * Fixes bug where only first arg in list of `required_unless_one` is recognized
* Fixes a typo bug `SubcommandsRequired`->`SubcommandRequired` * Fixes a typo bug `SubcommandsRequired`->`SubcommandRequired`
@ -553,7 +553,7 @@ The following is a list of optional `clap` features:
* **"suggestions"**: Turns on the `Did you mean '--myoption'?` feature for when users make typos. (builds dependency `strsim`) * **"suggestions"**: Turns on the `Did you mean '--myoption'?` feature for when users make typos. (builds dependency `strsim`)
* **"color"**: Turns on colored error messages. This feature only works on non-Windows OSs. (builds dependency `ansi-term` and `libc`) * **"color"**: Turns on colored error messages. This feature only works on non-Windows OSs. (builds dependency `ansi-term` and `libc`)
* **"wrap_help"**: Automatically detects terminal width and wraps long help text lines with proper indentation alignment (builds dependency `libc` and 'unicode-width') * **"wrap_help"**: Automatically detects terminal width and wraps long help text lines with proper indentation alignment (builds dependency `libc`, and `term_size`)
* **"lints"**: This is **not** included by default and should only be used while developing to run basic lints against changes. This can only be used on Rust nightly. (builds dependency `clippy`) * **"lints"**: This is **not** included by default and should only be used while developing to run basic lints against changes. This can only be used on Rust nightly. (builds dependency `clippy`)
* **"debug"**: This is **not** included by default and should only be used while developing to display debugging information. * **"debug"**: This is **not** included by default and should only be used while developing to display debugging information.
* **"yaml"**: This is **not** included by default. Enables building CLIs from YAML documents. (builds dependency `yaml-rust`) * **"yaml"**: This is **not** included by default. Enables building CLIs from YAML documents. (builds dependency `yaml-rust`)

View file

@ -23,17 +23,10 @@ mod term_size {
} }
} }
#[cfg(all(feature = "wrap_help", not(target_os = "windows")))]
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
use strext::_StrExt; use strext::_StrExt;
#[cfg(any(not(feature = "wrap_help"), target_os = "windows"))]
fn str_width(s: &str) -> usize {
s.len()
}
#[cfg(all(feature = "wrap_help", not(target_os = "windows")))]
fn str_width(s: &str) -> usize { fn str_width(s: &str) -> usize {
UnicodeWidthStr::width(s) UnicodeWidthStr::width(s)
} }

View file

@ -409,14 +409,12 @@ extern crate ansi_term;
extern crate yaml_rust; extern crate yaml_rust;
#[cfg(any(feature = "wrap_help", feature = "color"))] #[cfg(any(feature = "wrap_help", feature = "color"))]
extern crate libc; extern crate libc;
#[cfg(all(feature = "wrap_help", not(target_os = "windows")))]
extern crate unicode_width; extern crate unicode_width;
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;
extern crate vec_map; extern crate vec_map;
#[cfg(feature = "wrap_help")] #[cfg(feature = "wrap_help")]
extern crate term_size; extern crate term_size;
#[cfg(feature = "wrap_help")]
extern crate unicode_segmentation; extern crate unicode_segmentation;
#[cfg(feature = "yaml")] #[cfg(feature = "yaml")]