From d240ef1e922ac778885e13e5dbac2082abacd94f Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 26 Jun 2024 10:57:22 +0200 Subject: [PATCH] router: set help context on help invocation instead of during parsing... Signed-off-by: Wolfgang Bumiller --- proxmox-router/src/cli/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/proxmox-router/src/cli/mod.rs b/proxmox-router/src/cli/mod.rs index 697145dc..37dc73c2 100644 --- a/proxmox-router/src/cli/mod.rs +++ b/proxmox-router/src/cli/mod.rs @@ -415,6 +415,7 @@ struct CommandLineParseState<'cli> { global_option_values: HashMap, global_option_types: HashMap, async_run: Option Result>, + interface: Arc, } impl CommandLine { @@ -442,12 +443,10 @@ impl CommandLine { global_option_values: HashMap::new(), global_option_types: HashMap::new(), async_run: self.async_run, + interface: Arc::clone(&self.interface), }; - command::set_help_context(Some(Arc::clone(&self.interface))); - let out = state.parse_do(&self.interface, rpcenv, args); - command::set_help_context(None); - out + state.parse_do(&self.interface, rpcenv, args) } } @@ -541,9 +540,14 @@ impl<'cli> CommandLineParseState<'cli> { ) -> Result, Error> { let args = self.handle_current_global_options(args)?; self.build_global_options(&mut *rpcenv)?; + let interface = Arc::clone(&self.interface); Ok(Invocation { call: Box::new(move |rpcenv| { - command::handle_simple_command(&self.prefix, cli, args, rpcenv, self.async_run) + command::set_help_context(Some(interface)); + let out = + command::handle_simple_command(&self.prefix, cli, args, rpcenv, self.async_run); + command::set_help_context(None); + out }), }) }