Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement App::find_subcommand_mut #3306

Merged
merged 1 commit into from Jan 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/build/app/mod.rs
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