From 4878f7b7b18036ba9ba4c1cff3f29fbca212adee Mon Sep 17 00:00:00 2001 From: Danil Kondratiev Date: Thu, 20 Aug 2020 15:44:29 +0300 Subject: [PATCH 1/2] don't print spaces in long help --- src/output/help.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/output/help.rs b/src/output/help.rs index c3d624c4..ad114a26 100644 --- a/src/output/help.rs +++ b/src/output/help.rs @@ -353,7 +353,10 @@ impl<'help, 'app, 'parser, 'writer> Help<'help, 'app, 'parser, 'writer> { && h_w > (self.term_w - taken); debug!("Help::val: Has switch..."); - if arg.has_switch() { + if self.use_long { + // long help prints messages on the next line so it don't need to align text + debug!("Help::val: printing long help so skip aligment"); + } else if arg.has_switch() { debug!("Yes"); debug!("Help::val: force_next_line...{:?}", self.force_next_line); debug!("Help::val: nlh...{:?}", nlh); From 5b07c8a780f7214b21a451f2e2f24e467b2b03a8 Mon Sep 17 00:00:00 2001 From: Danil Kondratiev Date: Thu, 20 Aug 2020 15:45:38 +0300 Subject: [PATCH 2/2] fix spaces in long help tests --- tests/help.rs | 20 ++++++++++---------- tests/hidden_args.rs | 14 +++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/help.rs b/tests/help.rs index ce7f64c2..ce2e3fe5 100644 --- a/tests/help.rs +++ b/tests/help.rs @@ -111,10 +111,10 @@ USAGE: clap-test FLAGS: - -h, --help + -h, --help Prints help information - -V, --version + -V, --version Prints version information @@ -361,16 +361,16 @@ USAGE: prog [FLAGS] FLAGS: - --config + --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 + -h, --help Prints help information - -V, --version + -V, --version Prints version information"; static CUSTOM_VERSION_AND_HELP: &str = "customize 0.1 @@ -522,14 +522,14 @@ USAGE: myapp [arg1] ARGS: - + some option FLAGS: - -h, --help + -h, --help Prints help information - -V, --version + -V, --version Prints version information"; static HIDE_ENV_VALS: &str = "ctest 0.1 @@ -1626,10 +1626,10 @@ USAGE: ctest foo FLAGS: - -h, --help + -h, --help Prints help information - -V, --version + -V, --version Prints version information"; #[test] diff --git a/tests/hidden_args.rs b/tests/hidden_args.rs index ee98ab64..715f61a1 100644 --- a/tests/hidden_args.rs +++ b/tests/hidden_args.rs @@ -57,16 +57,16 @@ USAGE: test [FLAGS] FLAGS: - -c, --config + -c, --config Some help text describing the --config arg - -h, --help + -h, --help Prints help information - -V, --version + -V, --version Prints version information - -v, --visible + -v, --visible This text should be visible"; /// Ensure hidden with short option @@ -131,13 +131,13 @@ USAGE: test [FLAGS] FLAGS: - -h, --help + -h, --help Prints help information - -V, --version + -V, --version Prints version information - -v, --visible + -v, --visible This text should be visible"; #[test]