Skip to content

Commit

Permalink
feat: allows distinguishing between short and long help with subcomma…
Browse files Browse the repository at this point in the history
…nds in the same manner as args

One can use `App::about` for `-h` short help messsages or
`App::long_about` for `--help` long help messages.
  • Loading branch information
kbknapp committed Apr 5, 2017
1 parent ef1b24c commit 6b37189
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ impl<'a, 'b> App<'a, 'b> {
}

/// Sets a string describing what the program does. This will be displayed when displaying help
/// information.
/// information with `-h`.
///
/// **NOTE:** If only `about` is provided, and not [`App::long_about`] but the user requests
/// `--help` clap will still display the contents of `about` appropriately
///
/// **NOTE:** Only [`App::about`] is used in completion script generation in order to be
/// concise
///
/// # Examples
///
Expand All @@ -210,11 +216,38 @@ impl<'a, 'b> App<'a, 'b> {
/// .about("Does really amazing things to great people")
/// # ;
/// ```
/// [`App::long_about`]: ./struct.App.html#method.long_about
pub fn about<S: Into<&'b str>>(mut self, about: S) -> Self {
self.p.meta.about = Some(about.into());
self
}

/// Sets a string describing what the program does. This will be displayed when displaying help
/// information.
///
/// **NOTE:** If only `long_about` is provided, and not [`App::about`] but the user requests
/// `-h` clap will still display the contents of `long_about` appropriately
///
/// **NOTE:** Only [`App::about`] is used in completion script generation in order to be
/// concise
///
/// # Examples
///
/// ```no_run
/// # use clap::{App, Arg};
/// App::new("myprog")
/// .long_about(
/// "Does really amazing things to great people. Now let's talk a little
/// more in depth about how this subcommand really works. It may take about
/// a few lines of text, but that's ok!")
/// # ;
/// ```
/// [`App::about`]: ./struct.App.html#method.about
pub fn long_about<S: Into<&'b str>>(mut self, about: S) -> Self {
self.p.meta.long_about = Some(about.into());
self
}

/// Sets the program's name. This will be displayed when displaying help information.
///
/// **Pro-top:** This function is particularly useful when configuring a program via
Expand Down

0 comments on commit 6b37189

Please sign in to comment.