Skip to content

Commit

Permalink
fix(Help Message): fixes long_about not being usable
Browse files Browse the repository at this point in the history
Closes #1043
  • Loading branch information
kbknapp committed Sep 13, 2017
1 parent 2094c28 commit a8257ea
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
23 changes: 21 additions & 2 deletions src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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, &[]))?;
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a8257ea

Please sign in to comment.