From 03f445c9e6d7ee68642f9a6bbde45adb4864c05f Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Wed, 18 Mar 2026 17:17:25 -0600 Subject: [PATCH] expand api for CliApp --- src/cli.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 2377f90..2b12dc4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -54,16 +54,23 @@ impl }; self } - pub fn run(self, args: impl IntoIterator) -> Result<(), RpcError> { + fn command(&mut self) -> clap::Command { let mut cmd = Config::command(); for (name, handler) in &self.root_handler.subcommands.1 { if let (Name(name), Some(cli)) = (name, handler.cli()) { cmd = cmd.subcommand(cli.cli_command().name(name)); } } - if let Some(f) = self.mut_cmd { + if let Some(f) = self.mut_cmd.take() { cmd = f(cmd); } + cmd + } + pub fn into_command(mut self) -> clap::Command { + self.command() + } + pub fn run(mut self, args: impl IntoIterator) -> Result<(), RpcError> { + let cmd = self.command(); let matches = cmd.get_matches_from(args); let config = Config::from_arg_matches(&matches)?; let ctx = (self.make_ctx)(config)?;