allow chaining mutate_command

This commit is contained in:
Aiden McClelland
2026-03-18 13:57:14 -06:00
parent 39e547ff99
commit edb0731055

View File

@@ -47,7 +47,11 @@ impl<Context: crate::Context + Clone, Config: CommandFactory + FromArgMatches>
mut self, mut self,
f: impl FnOnce(clap::Command) -> clap::Command + Send + Sync + 'static, f: impl FnOnce(clap::Command) -> clap::Command + Send + Sync + 'static,
) -> Self { ) -> Self {
self.mut_cmd = Some(Box::new(f)); self.mut_cmd = if let Some(prev) = self.mut_cmd.take() {
Some(Box::new(|cmd| f(prev(cmd))))
} else {
Some(Box::new(f))
};
self self
} }
pub fn run(self, args: impl IntoIterator<Item = OsString>) -> Result<(), RpcError> { pub fn run(self, args: impl IntoIterator<Item = OsString>) -> Result<(), RpcError> {