forked from proxmox-mirrors/proxmox
router: set help context on help invocation
instead of during parsing... Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
83b3c1794a
commit
d240ef1e92
@ -415,6 +415,7 @@ struct CommandLineParseState<'cli> {
|
|||||||
global_option_values: HashMap<String, String>,
|
global_option_values: HashMap<String, String>,
|
||||||
global_option_types: HashMap<TypeId, &'cli GlobalOptions>,
|
global_option_types: HashMap<TypeId, &'cli GlobalOptions>,
|
||||||
async_run: Option<fn(ApiFuture) -> Result<Value, Error>>,
|
async_run: Option<fn(ApiFuture) -> Result<Value, Error>>,
|
||||||
|
interface: Arc<CommandLineInterface>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommandLine {
|
impl CommandLine {
|
||||||
@ -442,12 +443,10 @@ impl CommandLine {
|
|||||||
global_option_values: HashMap::new(),
|
global_option_values: HashMap::new(),
|
||||||
global_option_types: HashMap::new(),
|
global_option_types: HashMap::new(),
|
||||||
async_run: self.async_run,
|
async_run: self.async_run,
|
||||||
|
interface: Arc::clone(&self.interface),
|
||||||
};
|
};
|
||||||
|
|
||||||
command::set_help_context(Some(Arc::clone(&self.interface)));
|
state.parse_do(&self.interface, rpcenv, args)
|
||||||
let out = state.parse_do(&self.interface, rpcenv, args);
|
|
||||||
command::set_help_context(None);
|
|
||||||
out
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,9 +540,14 @@ impl<'cli> CommandLineParseState<'cli> {
|
|||||||
) -> Result<Invocation<'cli>, Error> {
|
) -> Result<Invocation<'cli>, Error> {
|
||||||
let args = self.handle_current_global_options(args)?;
|
let args = self.handle_current_global_options(args)?;
|
||||||
self.build_global_options(&mut *rpcenv)?;
|
self.build_global_options(&mut *rpcenv)?;
|
||||||
|
let interface = Arc::clone(&self.interface);
|
||||||
Ok(Invocation {
|
Ok(Invocation {
|
||||||
call: Box::new(move |rpcenv| {
|
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
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user