* [pbs-devel] [PATCH proxmox] fix prefix for nested commands
@ 2020-11-05 10:03 Fabian Ebner
2020-11-05 10:23 ` [pbs-devel] applied: " Wolfgang Bumiller
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Ebner @ 2020-11-05 10:03 UTC (permalink / raw)
To: pbs-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pbs-devel] applied: [PATCH proxmox] fix prefix for nested commands
2020-11-05 10:03 [pbs-devel] [PATCH proxmox] fix prefix for nested commands Fabian Ebner
@ 2020-11-05 10:23 ` Wolfgang Bumiller
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2020-11-05 10:23 UTC (permalink / raw)
To: Fabian Ebner; +Cc: pbs-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-05 10:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 10:03 [pbs-devel] [PATCH proxmox] fix prefix for nested commands Fabian Ebner
2020-11-05 10:23 ` [pbs-devel] applied: " Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox