Skip to content

Commit

Permalink
Clap v3 update: keygen (solana-labs#24479)
Browse files Browse the repository at this point in the history
* update clap to v3: keygen

* use clap-v3-utils

* update Cargo.lock

* address PR comments

* get rid of unnecessary generic for clap validator
  • Loading branch information
KirillLykov authored Apr 22, 2022
1 parent 0d51596 commit a221014
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 90 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 6 additions & 12 deletions clap-v3-utils/src/input_validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ where

// Return an error if string cannot be parsed as type T.
// Takes a String to avoid second type parameter when used as a clap validator
pub fn is_parsable<T>(string: String) -> Result<(), String>
pub fn is_parsable<T>(string: &str) -> Result<(), String>
where
T: FromStr,
T::Err: Display,
{
is_parsable_generic::<T, String>(string)
is_parsable_generic::<T, &str>(string)
}

// Return an error if string cannot be parsed as numeric type T, and value not within specified
Expand All @@ -57,10 +57,7 @@ where
}

// Return an error if a pubkey cannot be parsed.
pub fn is_pubkey<T>(string: T) -> Result<(), String>
where
T: AsRef<str> + Display,
{
pub fn is_pubkey(string: &str) -> Result<(), String> {
is_parsable_generic::<Pubkey, _>(string)
}

Expand Down Expand Up @@ -96,14 +93,11 @@ where
}

// Return an error if a `SignerSourceKind::Prompt` cannot be parsed
pub fn is_prompt_signer_source<T>(string: T) -> Result<(), String>
where
T: AsRef<str> + Display,
{
if string.as_ref() == ASK_KEYWORD {
pub fn is_prompt_signer_source(string: &str) -> Result<(), String> {
if string == ASK_KEYWORD {
return Ok(());
}
match parse_signer_source(string.as_ref())
match parse_signer_source(string)
.map_err(|err| format!("{}", err))?
.kind
{
Expand Down
4 changes: 2 additions & 2 deletions keygen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ edition = "2021"

[dependencies]
bs58 = "0.4.0"
clap = "2.33"
clap = { version = "3.1.5", features = ["cargo"] }
dirs-next = "2.0.0"
num_cpus = "1.13.1"
solana-clap-utils = { path = "../clap-utils", version = "=1.11.0" }
solana-clap-v3-utils = { path = "../clap-v3-utils", version = "=1.11.0" }
solana-cli-config = { path = "../cli-config", version = "=1.11.0" }
solana-remote-wallet = { path = "../remote-wallet", version = "=1.11.0" }
solana-sdk = { path = "../sdk", version = "=1.11.0" }
Expand Down
Loading

0 comments on commit a221014

Please sign in to comment.