From a8257ea0ffb812e552aca256c4a3d2aebfd8065b Mon Sep 17 00:00:00 2001 From: Kevin K Date: Wed, 13 Sep 2017 11:41:19 -0700 Subject: [PATCH] fix(Help Message): fixes long_about not being usable Closes #1043 --- src/app/help.rs | 23 +++++++++++++++++++++-- src/app/parser.rs | 3 ++- src/lib.rs | 1 - 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/app/help.rs b/src/app/help.rs index db34ceabd06..223e7ae5c64 100644 --- a/src/app/help.rs +++ b/src/app/help.rs @@ -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, &[]))?; } diff --git a/src/app/parser.rs b/src/app/parser.rs index c20ab0b6558..025fd47d9f6 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 73e74f11277..468dd5967e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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;