Add helper function for adding command to Commands

This commit is contained in:
Joscha 2024-12-29 16:10:58 +01:00
parent 191edc648d
commit 270a2b48d9

View file

@ -153,6 +153,13 @@ pub trait CommandExt: Sized {
fn clap(self) -> clap::Clap<Self> { fn clap(self) -> clap::Clap<Self> {
clap::Clap(self) clap::Clap(self)
} }
fn add_to<E>(self, commands: &mut Commands<E>)
where
Self: Command<E> + Send + Sync + 'static,
{
commands.add(self);
}
} }
// Sadly this doesn't work: `impl<E, C: Command<E>> CommandExt for C {}` // Sadly this doesn't work: `impl<E, C: Command<E>> CommandExt for C {}`