From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Fabian Ebner <f.ebner@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH proxmox] fix prefix for nested commands
Date: Thu, 5 Nov 2020 11:23:31 +0100 [thread overview]
Message-ID: <20201105102331.dz6y2s4i6orekkab@olga.proxmox.com> (raw)
In-Reply-To: <20201105100301.4212-1-f.ebner@proxmox.com>
applied
On Thu, Nov 05, 2020 at 11:03:01AM +0100, Fabian Ebner wrote:
> Fixes a regression from commit f50a627f340ca2ae018079e431edd5a127638458
> which resulted in re-using the prefix without sub-commands when calling
> handle_simple_command(_future)
>
> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
> ---
>
> For example,
> proxmox-backup-manager user create foo
> is affected by this and printed:
> Usage: proxmox-backup-manager <userid> [OPTIONS]
> instead of:
> Usage: proxmox-backup-manager user create <userid> [OPTIONS]
>
> proxmox/src/api/cli/command.rs | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/proxmox/src/api/cli/command.rs b/proxmox/src/api/cli/command.rs
> index 53e3d93..89dfdf1 100644
> --- a/proxmox/src/api/cli/command.rs
> +++ b/proxmox/src/api/cli/command.rs
> @@ -148,12 +148,11 @@ fn handle_simple_command(
> }
>
> fn parse_nested_command<'a>(
> - prefix: &str,
> + prefix: &mut String,
> def: &'a CliCommandMap,
> args: &mut Vec<String>,
> ) -> Result<&'a CliCommand, Error> {
> let mut map = def;
> - let mut prefix = prefix.to_string();
>
> // Note: Avoid async recursive function, because current rust compiler cant handle that
> loop {
> @@ -185,7 +184,7 @@ fn parse_nested_command<'a>(
> }
> };
>
> - prefix = format!("{} {}", prefix, command);
> + *prefix = format!("{} {}", prefix, command);
>
> match sub_cmd {
> CommandLineInterface::Simple(cli_cmd) => {
> @@ -277,7 +276,8 @@ pub async fn handle_command_future(
> handle_simple_command_future(&prefix, &cli_cmd, args, rpcenv).await
> }
> CommandLineInterface::Nested(ref map) => {
> - let cli_cmd = parse_nested_command(&prefix, &map, &mut args)?;
> + let mut prefix = prefix.to_string();
> + let cli_cmd = parse_nested_command(&mut prefix, &map, &mut args)?;
> handle_simple_command_future(&prefix, &cli_cmd, args, rpcenv).await
> }
> };
> @@ -305,7 +305,8 @@ pub fn handle_command(
> handle_simple_command(&prefix, &cli_cmd, args, rpcenv, run)
> }
> CommandLineInterface::Nested(ref map) => {
> - let cli_cmd = parse_nested_command(&prefix, &map, &mut args)?;
> + let mut prefix = prefix.to_string();
> + let cli_cmd = parse_nested_command(&mut prefix, &map, &mut args)?;
> handle_simple_command(&prefix, &cli_cmd, args, rpcenv, run)
> }
> };
> --
> 2.20.1
prev parent reply other threads:[~2020-11-05 10:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 10:03 [pbs-devel] " Fabian Ebner
2020-11-05 10:23 ` Wolfgang Bumiller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201105102331.dz6y2s4i6orekkab@olga.proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=f.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox