Merge branch 'master' of github.com:kbknapp/clap-rs

This commit is contained in:
Kevin K 2016-09-05 22:12:12 -04:00
commit 0d503504d2
5 changed files with 35 additions and 19 deletions

View file

@ -1,3 +1,12 @@
<a name="v2.11.2"></a>
### v2.11.2 (2016-09-06)
#### Improvements
* **Help Wrapping:** makes some minor changes to when next line help is automatically used ([5658b117](https://github.com/kbknapp/clap-rs/commit/5658b117aec3e03adff9c8c52a4c4bc1fcb4e1ff))
<a name="v2.11.1"></a> <a name="v2.11.1"></a>
### v2.11.1 (2016-09-05) ### v2.11.1 (2016-09-05)

View file

@ -1,7 +1,7 @@
[package] [package]
name = "clap" name = "clap"
version = "2.11.1" version = "2.11.2"
authors = ["Kevin K. <kbknapp@gmail.com>"] authors = ["Kevin K. <kbknapp@gmail.com>"]
exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"] exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"]
repository = "https://github.com/kbknapp/clap-rs.git" repository = "https://github.com/kbknapp/clap-rs.git"

View file

@ -39,6 +39,10 @@ Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc)
## What's New ## What's New
Here's the highlights for v2.11.2
* Makes some minor changes to when next line help is automatically used for improved wrapping
Here's the highlights for v2.11.1 Here's the highlights for v2.11.1
* Fixes an issue where settings weren't propogated down through grand-child subcommands * Fixes an issue where settings weren't propogated down through grand-child subcommands

View file

@ -314,7 +314,7 @@ impl<'a> Help<'a> {
let width = self.term_w; let width = self.term_w;
let taken = (longest + 12) + str_width(&*spec_vals); let taken = (longest + 12) + str_width(&*spec_vals);
let force_next_line = !nlh && width >= taken && let force_next_line = !nlh && width >= taken &&
(taken as f32 / width as f32) > 0.35 && (taken as f32 / width as f32) > 0.40 &&
str_width(h) > (width - taken); str_width(h) > (width - taken);
if arg.has_switch() { if arg.has_switch() {
@ -404,7 +404,7 @@ impl<'a> Help<'a> {
// We calculate with longest+12 since if it's already NLH we don't care // We calculate with longest+12 since if it's already NLH we don't care
let taken = (longest + 12) + str_width(&*spec_vals); let taken = (longest + 12) + str_width(&*spec_vals);
let force_next_line = !nlh && width >= taken && let force_next_line = !nlh && width >= taken &&
(taken as f32 / width as f32) > 0.35 && (taken as f32 / width as f32) > 0.40 &&
str_width(h) > (width - taken); str_width(h) > (width - taken);
debugln!("Force Next Line...{:?}", force_next_line); debugln!("Force Next Line...{:?}", force_next_line);
debugln!("Force Next Line math (help_len > (width - flags/opts/spcs))...{} > ({} - {})", debugln!("Force Next Line math (help_len > (width - flags/opts/spcs))...{} > ({} - {})",
@ -413,7 +413,7 @@ impl<'a> Help<'a> {
taken); taken);
let spcs = if nlh || force_next_line { let spcs = if nlh || force_next_line {
8 // "tab" + "tab" 12 // "tab" * 3
} else { } else {
longest + 12 longest + 12
}; };
@ -421,7 +421,7 @@ impl<'a> Help<'a> {
let too_long = spcs + str_width(h) + str_width(&*spec_vals) >= width; let too_long = spcs + str_width(h) + str_width(&*spec_vals) >= width;
debugln!("Spaces: {}", spcs); debugln!("Spaces: {}", spcs);
// Is help on next line, if so newline + 2x tab // Is help on next line, if so then indent
if nlh || force_next_line { if nlh || force_next_line {
try!(write!(self.writer, "\n{}{}{}", TAB, TAB, TAB)); try!(write!(self.writer, "\n{}{}{}", TAB, TAB, TAB));
} }

View file

@ -91,13 +91,15 @@ FLAGS:
-V, --version Prints version information -V, --version Prints version information
OPTIONS: OPTIONS:
-c, --cafe <FILE> -c, --cafe <FILE> A coffeehouse, coffee shop, or café is an
A coffeehouse, coffee shop, or café is an establishment which establishment which primarily serves hot
primarily serves hot coffee, related coffee beverages coffee, related coffee beverages (e.g.,
(e.g., café latte, cappuccino, espresso), tea, and other café latte, cappuccino, espresso), tea,
hot beverages. Some coffeehouses also serve cold beverages and other hot beverages. Some
such as iced coffee and iced tea. Many cafés also serve coffeehouses also serve cold beverages
some type of food, such as light snacks, muffins, or pastries."; such as iced coffee and iced tea. Many
cafés also serve some type of food, such
as light snacks, muffins, or pastries.";
static ISSUE_626_PANIC: &'static str = "ctest 0.1 static ISSUE_626_PANIC: &'static str = "ctest 0.1
@ -110,13 +112,14 @@ FLAGS:
OPTIONS: OPTIONS:
-c, --cafe <FILE> -c, --cafe <FILE>
La culture du café est très développée dans La culture du café est très développée
de nombreux pays à climat chaud dans de nombreux pays à climat chaud
d\'Amérique, d\'Afrique et d\'Asie, dans d\'Amérique, d\'Afrique et d\'Asie,
des plantations qui sont cultivées pour dans des plantations qui sont
les marchés d\'exportation. Le café est cultivées pour les marchés
souvent une contribution majeure aux d\'exportation. Le café est souvent
exportations des régions productrices."; une contribution majeure aux
exportations des régions productrices.";
#[test] #[test]
fn help_short() { fn help_short() {