fix(Help Message): fixes long_about not being usable

Closes #1043
This commit is contained in:
Kevin K 2017-09-13 11:41:19 -07:00
parent 2094c28d15
commit a8257ea0ff
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A
3 changed files with 23 additions and 4 deletions

View file

@ -657,8 +657,22 @@ impl<'a> Help<'a> {
if let Some(author) = parser.meta.author {
write_thing!(author)
}
if let Some(about) = parser.meta.about {
write_thing!(about)
if self.use_long {
if let Some(about) = parser.meta.long_about {
debugln!("Help::write_default_help: writing long about");
write_thing!(about)
} else if let Some(about) = parser.meta.about {
debugln!("Help::write_default_help: writing about");
write_thing!(about)
}
} else {
if let Some(about) = parser.meta.about {
debugln!("Help::write_default_help: writing about");
write_thing!(about)
} else if let Some(about) = parser.meta.long_about {
debugln!("Help::write_default_help: writing long about");
write_thing!(about)
}
}
color!(self, "\nUSAGE:", warning)?;
@ -861,6 +875,11 @@ impl<'a> Help<'a> {
"{}",
parser.meta.about.unwrap_or("unknown about"))?;
}
b"long-about" => {
write!(self.writer,
"{}",
parser.meta.long_about.unwrap_or("unknown about"))?;
}
b"usage" => {
write!(self.writer, "{}", usage::create_usage_no_title(parser, &[]))?;
}

View file

@ -1339,7 +1339,8 @@ impl<'a, 'b> Parser<'a, 'b>
#[cfg_attr(feature = "cargo-clippy", allow(let_and_return))]
fn use_long_help(&self) -> bool {
let ul = self.flags.iter().any(|f| f.b.long_help.is_some()) ||
let ul = self.meta.long_about.is_some() ||
self.flags.iter().any(|f| f.b.long_help.is_some()) ||
self.opts.iter().any(|o| o.b.long_help.is_some()) ||
self.positionals.values().any(|p| p.b.long_help.is_some()) ||
self.subcommands

View file

@ -542,7 +542,6 @@ extern crate vec_map;
#[cfg(feature = "wrap_help")]
extern crate term_size;
extern crate textwrap;
extern crate unicode_segmentation;
#[cfg(feature = "color")]
extern crate atty;