Skip to content

Commit

Permalink
feat!: Allow resetting abouts/help to default
Browse files Browse the repository at this point in the history
I dislike the inconsistency with only a few fields providing this (this
and `help_heading`) but this is to address a specific bug.  We need to
visit this, along with iterators (clap-rs#2870) and string handling (clap-rs#2150).

`Arg` came along for the ride because the derive logic is applied to
both.  `PossibleValue` didn't need it because we filter out `long_help`.

BREAKING CHANGE: We changed the signatures for `App::about`,
`App::long_about`, `Arg::help`, and `Arg::long_help` from accepting anything `Into<&str>` to `&str`.
  • Loading branch information
epage committed Dec 14, 2021
1 parent 05cf230 commit dd499ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/build/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,8 @@ impl<'help> App<'help> {
/// .about("Does really amazing things for great people")
/// # ;
/// ```
pub fn about<S: Into<&'help str>>(mut self, about: S) -> Self {
self.about = Some(about.into());
pub fn about<O: Into<Option<&'help str>>>(mut self, about: O) -> Self {
self.about = about.into();
self
}

Expand All @@ -920,8 +920,8 @@ impl<'help> App<'help> {
/// # ;
/// ```
/// [`App::about`]: App::about()
pub fn long_about<S: Into<&'help str>>(mut self, about: S) -> Self {
self.long_about = Some(about.into());
pub fn long_about<O: Into<Option<&'help str>>>(mut self, long_about: O) -> Self {
self.long_about = long_about.into();
self
}

Expand Down
8 changes: 4 additions & 4 deletions src/build/arg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2712,8 +2712,8 @@ impl<'help> Arg<'help> {
/// ```
/// [`Arg::long_help`]: Arg::long_help()
#[inline]
pub fn help(mut self, h: &'help str) -> Self {
self.help = Some(h);
pub fn help(mut self, h: impl Into<Option<&'help str>>) -> Self {
self.help = h.into();
self
}

Expand Down Expand Up @@ -2773,8 +2773,8 @@ impl<'help> Arg<'help> {
/// ```
/// [`Arg::help`]: Arg::help()
#[inline]
pub fn long_help(mut self, h: &'help str) -> Self {
self.long_help = Some(h);
pub fn long_help(mut self, h: impl Into<Option<&'help str>>) -> Self {
self.long_help = h.into();
self
}

Expand Down

0 comments on commit dd499ab

Please sign in to comment.