Skip to content

Commit

Permalink
Merge pull request #3306 from sunshowers/sub
Browse files Browse the repository at this point in the history
implement App::find_subcommand_mut
  • Loading branch information
epage authored Jan 18, 2022
2 parents ccbbba8 + 236ec97 commit 784d249
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/build/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,18 @@ impl<'help> App<'help> {
self.get_subcommands().find(|s| s.aliases_to(name))
}

/// Find subcommand such that its name or one of aliases equals `name`, returning
/// a mutable reference to the subcommand.
///
/// This does not recurse through subcommands of subcommands.
#[inline]
pub fn find_subcommand_mut<T>(&mut self, name: &T) -> Option<&mut App<'help>>
where
T: PartialEq<str> + ?Sized,
{
self.get_subcommands_mut().find(|s| s.aliases_to(name))
}

/// Iterate through the set of arguments.
#[inline]
pub fn get_arguments(&self) -> impl Iterator<Item = &Arg<'help>> {
Expand Down

0 comments on commit 784d249

Please sign in to comment.