2058: Add blank line between items in long help r=pksunkara a=mkantor



Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
This commit is contained in:
bors[bot] 2020-08-11 23:30:48 +00:00 committed by GitHub
commit 9185366420
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 13 deletions

View file

@ -599,24 +599,24 @@ impl<'help> Arg<'help> {
/// The above example displays /// The above example displays
/// ///
/// ```text /// ```text
/// helptest /// prog
/// ///
/// USAGE: /// USAGE:
/// helptest [FLAGS] /// prog [FLAGS]
/// ///
/// FLAGS: /// FLAGS:
/// --config /// --config
/// The config file used by the myprog must be in JSON format /// The config file used by the myprog must be in JSON format
/// with only valid keys and may not contain other nonsense /// with only valid keys and may not contain other nonsense
/// that cannot be read by this program. Obviously I'm going on /// that cannot be read by this program. Obviously I'm going on
/// and on, so I'll stop now. /// and on, so I'll stop now.
/// ///
/// -h, --help /// -h, --help
/// Prints help information /// Prints help information
///
/// -V, --version
/// Prints version information
/// ///
/// -V, --version
/// Prints version information
/// ```
/// [`Arg::about`]: ./struct.Arg.html#method.about /// [`Arg::about`]: ./struct.Arg.html#method.about
#[inline] #[inline]
pub fn long_about(mut self, h: &'help str) -> Self { pub fn long_about(mut self, h: &'help str) -> Self {

View file

@ -454,7 +454,7 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> {
} }
self.none(part)?; self.none(part)?;
} }
if !prevent_nlh && !help.contains('\n') && (nlh || self.force_next_line) { if !prevent_nlh && (nlh || self.force_next_line) {
self.none("\n")?; self.none("\n")?;
} }
Ok(()) Ok(())

View file

@ -269,6 +269,7 @@ FLAGS:
-h, --help -h, --help
Prints help Prints help
information information
-V, --version -V, --version
Prints Prints
version version
@ -354,6 +355,24 @@ FLAGS:
Prints version Prints version
information"; information";
static ISSUE_1642: &str = "prog
USAGE:
prog [FLAGS]
FLAGS:
--config
The config file used by the myprog must be in JSON format
with only valid keys and may not contain other nonsense
that cannot be read by this program. Obviously I'm going on
and on, so I'll stop now.
-h, --help
Prints help information
-V, --version
Prints version information";
static CUSTOM_VERSION_AND_HELP: &str = "customize 0.1 static CUSTOM_VERSION_AND_HELP: &str = "customize 0.1
Nobody <odysseus@example.com> Nobody <odysseus@example.com>
You can customize the version and help text You can customize the version and help text
@ -1766,3 +1785,14 @@ fn help_required_and_no_args() {
.setting(AppSettings::HelpRequired) .setting(AppSettings::HelpRequired)
.get_matches(); .get_matches();
} }
#[test]
fn issue_1642_long_help_spacing() {
let app = App::new("prog").arg(Arg::new("cfg").long("config").long_about(
"The config file used by the myprog must be in JSON format
with only valid keys and may not contain other nonsense
that cannot be read by this program. Obviously I'm going on
and on, so I'll stop now.",
));
assert!(utils::compare_output(app, "prog --help", ISSUE_1642, false));
}