[clap-v3-utils] Replace pubkeys_sigs_of
with try_pubkeys_sigs_of
#34801
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Due to the differences in the way
value_of
andis_present
functions behave in clap-v2 and clap-v3, thetry_
versions of different key parsers were added in #33184. However, that PR missed a point in the logic insigner_from_path_with_config
wherepubkeys_sigs_of
is still used instead oftry_pubkeys_sigs_of
. The panicking behavior ofpubkeys_sigs_of
when called on a non pre-specified argument, it is blocking the token-cli from being upgraded to clap-v3.Summary of Changes
I replaced the
pubkeys_sigs_of
withtry_pubkeys_sigs_of
when parsingSignerSourceKind::Pubkey
.Technically, to be consistent with the rest of the module, we should call
try_pubkeys_sigs_of(matches, SIGNER_ARG.name)?
. However, this changes the behavior of the function. In clap-v2, ifpubkeys_sigs_of(matches, SIGNER_ARG.name)
is called whenSIGNER_ARG.name
is not pre-specified as a clap argument, then it returnsNone
. Therefore, instead of returning error, I invoked.ok().flatten()
on the resulting result value.There is a bigger PR in the works #34678 to clean up parsing of signer source. However, I just wanted to make sure that this change goes into 1.18, hence a smaller PR here.
Fixes #