Repository: clap-rs/clap (Rust)

Issue:
Configure help subcommand to print long form
### Please complete the following tasks

I have searched the [discussions](https://github.com/clap-rs/clap/discussions)
I have searched the existing issues

### Describe your use case

The `help` subcommand prints the short help form, and I would like to configure it to print the long form instead.

The long form is more inline with my expectations of what the `help` subcommand should return. For example, compare the output of `git help init`, `git init -h`, and `git init --help`. At least on my system, the subcommand produces the long form; not the short form.

### Describe the solution you'd like

Ideally this would be configurable via [AppSettings](https://docs.rs/clap/2.33.3/clap/enum.AppSettings.html).

### Alternatives, if applicable

_No response_

### Additional Context

_No response_




Discussion:
I would like to work on this 😄 
I have made a little bit of progress on this (added the setting and started integration tests). However, I am wondering how I would go about writing integration tests for this. Reading over the code base, I found `utils::compare_output()` but that seems to be for errors. 

(I am going to reformat and run clippy before I send the PR, so ignore that for now)

Here is an example of one of my tests, what is the best way to do this?
```rust
#[test]
fn subcommand_help_shows_long_form_with_setting_using_before_help() {
    let m = App::new("myprog")
        .setting(AppSettings::SubcommandHelpShowsLongForm)
        .subcommand(App::new("test")
            .before_help("short form help message")
            .before_long_help("long form help message"));
    assert!(utils::compare_output(
        m,
        "help test",
        SUBCOMMAND_HELP_LONG_FORM_USING_BEFORE_HELP,
        false)
    );
}
```
@reaganmcf `compare_output()` is not only for errors. It can be used for both stdout and stderr. There is nothing wrong with you test.
@ldm0 Currently the test above is pacnicking. Here is is the output:
```rust
---- subcommand_help_shows_long_form_with_setting_using_before_help stdout ----
thread 'subcommand_help_shows_long_form_with_setting_using_before_help' panicked at 
'called `Result::unwrap_err()` on an `Ok`  value: ArgMatches { args: {}, subcommand: Some(SubCommand { id: test, name: "test", matches: ArgMatches { args: {}, subcommand: None } }) }', 
tests/utils.rs:36:19
```
@reaganmcf Hmm, check this?:
```rust
    assert!(utils::compare_output(
        m,
        "myprog help test",
        SUBCOMMAND_HELP_LONG_FORM_USING_BEFORE_HELP,
        false)
    );
```



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d609d1b1382..5c1216facc8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,7 @@ TODO: `cargo`, `std` features
   * **Error**
     * `Error::print`
 * **Added Settings**
+  * `AppSettings::UseLongFormatForHelpSubcommand`
   * `ArgSettings::HideEnv`
 
 #### Enhancements
diff --git a/src/build/app/settings.rs b/src/build/app/settings.rs
index 0bdcd9d0b6f..f5b3529a683 100644
--- a/src/build/app/settings.rs
+++ b/src/build/app/settings.rs
@@ -48,6 +48,7 @@ bitflags! {
         const HELP_REQUIRED                  = 1 << 40;
         const SUBCOMMAND_PRECEDENCE_OVER_ARG = 1 << 41;
         const DISABLE_HELP_FLAG              = 1 << 42;
+        const USE_LONG_FORMAT_FOR_HELP_SC    = 1 << 43;
     }
 }
 
@@ -126,6 +127,8 @@ impl_settings! { AppSettings, AppFlags,
         => Flags::SC_REQUIRED,
     SubcommandRequiredElseHelp("subcommandrequiredelsehelp")
         => Flags::SC_REQUIRED_ELSE_HELP,
+    UseLongFormatForHelpSubcommand("uselongformatforhelpsubcommand")
+        => Flags::USE_LONG_FORMAT_FOR_HELP_SC,
     TrailingVarArg("trailingvararg")
         => Flags::TRAILING_VARARG,
     UnifiedHelpMessage("unifiedhelpmessage")
@@ -904,6 +907,28 @@ pub enum AppSettings {
     /// [``]: ./struct..html
     SubcommandRequiredElseHelp,
 
+    /// Specifies that the help subcommand should print the [long format] help message.
+    ///
+    /// **NOTE:** This setting is useless if [`AppSettings::DisableHelpSubcommand`] or [`AppSettings::NoAutoHelp`] is set,
+    /// or if the app contains no subcommands at all.
+    ///
+    /// # Examples
+    ///
+    /// ```rust
+    /// # use clap::{App, Arg, AppSettings};
+    /// App::new("myprog")
+    ///     .setting(AppSettings::UseLongFormatForHelpSubcommand)
+    ///     .subcommand(App::new("test")
+    ///         .arg(Arg::new("foo")
+    ///             .about("short form about message")
+    ///             .long_about("long form about message")
+    ///         )
+    ///     )
+    ///     .get_matches();
+    /// ```
+    /// [long format]: App::long_about
+    UseLongFormatForHelpSubcommand,
+
     /// Specifies that any invalid UTF-8 code points should be treated as an error and fail
     /// with a [`ErrorKind::InvalidUtf8`] error.
     ///
@@ -1159,6 +1184,12 @@ mod test {
             "subcommandrequiredelsehelp".parse::<AppSettings>().unwrap(),
             AppSettings::SubcommandRequiredElseHelp
         );
+        assert_eq!(
+            "uselongformatforhelpsubcommand"
+                .parse::<AppSettings>()
+                .unwrap(),
+            AppSettings::UseLongFormatForHelpSubcommand
+        );
         assert_eq!(
             "strictutf8".parse::<AppSettings>().unwrap(),
             AppSettings::StrictUtf8
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index 4604e7fbeff..f6ce5224c91 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -808,7 +808,7 @@ impl<'help, 'app> Parser<'help, 'app> {
             parser.app.bin_name = Some(format!("{} {}", bin_name, parser.app.name));
         }
 
-        Err(parser.help_err(false))
+        Err(parser.help_err(self.app.is_set(AS::UseLongFormatForHelpSubcommand)))
     }
 
     fn is_new_arg(&self, arg_os: &ArgStr, last_result: &ParseResult) -> bool {


Test patch:
diff --git a/tests/app_settings.rs b/tests/app_settings.rs
index 3988ce60fcc..8dc6172e259 100644
--- a/tests/app_settings.rs
+++ b/tests/app_settings.rs
@@ -97,6 +97,57 @@ SUBCOMMANDS:
     help    Prints this message or the help of the given subcommand(s)
     info";
 
+static LONG_FORMAT_FOR_HELP_SUBCOMMAND: &str = "myprog-test 
+
+USAGE:
+    myprog test [foo]
+
+ARGS:
+    <foo>
+            long form about message
+
+FLAGS:
+    -h, --help
+            Prints help information
+
+    -V, --version
+            Prints version information";
+
+static LONG_FORMAT_FOR_NESTED_HELP_SUBCOMMAND: &str = "myprog-test-nested 
+
+long form about message
+
+USAGE:
+    myprog test nested
+
+FLAGS:
+    -h, --help
+            Prints help information
+
+    -V, --version
+            Prints version information";
+
+static LONG_FORMAT_SINGLE_ARG_HELP_SUBCOMMAND: &str = "myprog 
+
+USAGE:
+    myprog [foo] [SUBCOMMAND]
+
+ARGS:
+    <foo>
+            long form about message
+
+FLAGS:
+    -h, --help
+            Prints help information
+
+    -V, --version
+            Prints version information
+
+SUBCOMMANDS:
+    help
+            Prints this message or the help of the given subcommand(s)
+    test";
+
 #[test]
 fn sub_command_negate_required() {
     App::new("sub_command_negate")
@@ -1022,3 +1073,59 @@ fn aaos_option_use_delim_false() {
         &["one,two"]
     );
 }
+
+#[test]
+fn nested_help_subcommand_with_global_setting() {
+    let m = App::new("myprog")
+        .global_setting(AppSettings::UseLongFormatForHelpSubcommand)
+        .subcommand(
+            App::new("test").subcommand(
+                App::new("nested")
+                    .about("short form about message")
+                    .long_about("long form about message"),
+            ),
+        );
+    assert!(utils::compare_output(
+        m,
+        "myprog test help nested",
+        LONG_FORMAT_FOR_NESTED_HELP_SUBCOMMAND,
+        false
+    ));
+}
+
+#[test]
+fn single_arg_help_with_long_format_setting() {
+    let m = App::new("myprog")
+        .setting(AppSettings::UseLongFormatForHelpSubcommand)
+        .subcommand(App::new("test"))
+        .arg(
+            Arg::new("foo")
+                .about("short form about message")
+                .long_about("long form about message"),
+        );
+    assert!(utils::compare_output(
+        m,
+        "myprog help",
+        LONG_FORMAT_SINGLE_ARG_HELP_SUBCOMMAND,
+        false
+    ));
+}
+
+#[test]
+fn use_long_format_for_help_subcommand_with_setting() {
+    let m = App::new("myprog")
+        .setting(AppSettings::UseLongFormatForHelpSubcommand)
+        .subcommand(
+            App::new("test").arg(
+                Arg::new("foo")
+                    .about("short form about message")
+                    .long_about("long form about message"),
+            ),
+        );
+    assert!(utils::compare_output(
+        m,
+        "myprog help test",
+        LONG_FORMAT_FOR_HELP_SUBCOMMAND,
+        false
+    ));
+}