From cf8e32a5ec195768c183784f2b91054719be1109 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 14 Jan 2025 01:43:55 +0100 Subject: [PATCH 1/2] cli: Fix multisig parsing #### Problem As pointed out in #58, the CLI currently fails when just running `create-account `, because a multisig argument is expected during all commands. Clap v3's version of `values_of` gives an error if the arg is not configured in the command. This was probably missed during the port over to clap v3. #### Summary of changes Do the same thing as elsewhere, and change `values_of` to `try_get_many(...).ok().flatten()`. This is the last place using `values_of` in the CLI that could fail. --- clients/cli/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/src/config.rs b/clients/cli/src/config.rs index fe05b47ce..33110e4fa 100644 --- a/clients/cli/src/config.rs +++ b/clients/cli/src/config.rs @@ -48,9 +48,9 @@ fn signers_of( name: &str, wallet_manager: &mut Option>, ) -> Result, Box> { - if let Some(values) = matches.values_of(name) { + if let Some(values) = matches.try_get_many(name).ok().flatten() { let mut results = Vec::new(); - for (i, value) in values.enumerate() { + for (i, value) in values.copied().enumerate() { let name = format!("{}-{}", name, i.saturating_add(1)); let signer = signer_from_path(matches, value, &name, wallet_manager)?; let signer_pubkey = signer.pubkey(); From 4f47552656d6409543cc8c6387ff745da42dad26 Mon Sep 17 00:00:00 2001 From: Jon C Date: Tue, 14 Jan 2025 12:18:26 +0100 Subject: [PATCH 2/2] Integrate review feedback --- clients/cli/src/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clients/cli/src/config.rs b/clients/cli/src/config.rs index 33110e4fa..cec32de19 100644 --- a/clients/cli/src/config.rs +++ b/clients/cli/src/config.rs @@ -48,9 +48,9 @@ fn signers_of( name: &str, wallet_manager: &mut Option>, ) -> Result, Box> { - if let Some(values) = matches.try_get_many(name).ok().flatten() { + if let Some(values) = matches.try_get_many::(name).ok().flatten() { let mut results = Vec::new(); - for (i, value) in values.copied().enumerate() { + for (i, value) in values.enumerate() { let name = format!("{}-{}", name, i.saturating_add(1)); let signer = signer_from_path(matches, value, &name, wallet_manager)?; let signer_pubkey = signer.pubkey();