Skip to content

Commit

Permalink
repalce is_parsable with parser
Browse files Browse the repository at this point in the history
  • Loading branch information
samkim-crypto committed Nov 3, 2024
1 parent a3527b7 commit 4c65024
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
8 changes: 4 additions & 4 deletions token/cli/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) async fn bench_process_command(
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
.unwrap()
.unwrap();
let n = value_t_or_exit!(arg_matches, "n", usize);
let n = *arg_matches.get_one::<usize>("n").unwrap();

let (owner_signer, owner) =
config.signer_or_default(arg_matches, "owner", wallet_manager);
Expand All @@ -46,7 +46,7 @@ pub(crate) async fn bench_process_command(
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
.unwrap()
.unwrap();
let n = value_t_or_exit!(arg_matches, "n", usize);
let n = *arg_matches.get_one::<usize>("n").unwrap();
let (owner_signer, owner) =
config.signer_or_default(arg_matches, "owner", wallet_manager);
signers.push(owner_signer);
Expand All @@ -57,7 +57,7 @@ pub(crate) async fn bench_process_command(
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
.unwrap()
.unwrap();
let n = value_t_or_exit!(arg_matches, "n", usize);
let n = *arg_matches.get_one::<usize>("n").unwrap();
let ui_amount = *arg_matches.get_one::<Amount>("amount").unwrap();
let (owner_signer, owner) =
config.signer_or_default(arg_matches, "owner", wallet_manager);
Expand All @@ -72,7 +72,7 @@ pub(crate) async fn bench_process_command(
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
.unwrap()
.unwrap();
let n = value_t_or_exit!(arg_matches, "n", usize);
let n = *arg_matches.get_one::<usize>("n").unwrap();
let ui_amount = *arg_matches.get_one::<Amount>("amount").unwrap();
let (owner_signer, owner) =
config.signer_or_default(arg_matches, "owner", wallet_manager);
Expand Down
16 changes: 7 additions & 9 deletions token/cli/src/clap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use {
solana_clap_v3_utils::{
fee_payer::fee_payer_arg,
input_parsers::Amount,
input_validators::{
is_parsable, is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer,
},
input_validators::{is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer},
memo::memo_arg,
nonce::*,
offline::{self, *},
Expand Down Expand Up @@ -473,7 +471,7 @@ impl BenchSubCommand for App<'_> {
)
.arg(
Arg::with_name("n")
.validator(is_parsable::<usize>)
.value_parser(clap::value_parser!(usize))
.value_name("N")
.takes_value(true)
.index(2)
Expand All @@ -496,7 +494,7 @@ impl BenchSubCommand for App<'_> {
)
.arg(
Arg::with_name("n")
.validator(is_parsable::<usize>)
.value_parser(clap::value_parser!(usize))
.value_name("N")
.takes_value(true)
.index(2)
Expand All @@ -519,7 +517,7 @@ impl BenchSubCommand for App<'_> {
)
.arg(
Arg::with_name("n")
.validator(is_parsable::<usize>)
.value_parser(clap::value_parser!(usize))
.value_name("N")
.takes_value(true)
.index(2)
Expand Down Expand Up @@ -559,7 +557,7 @@ impl BenchSubCommand for App<'_> {
)
.arg(
Arg::with_name("n")
.validator(is_parsable::<usize>)
.value_parser(clap::value_parser!(usize))
.value_name("N")
.takes_value(true)
.index(2)
Expand Down Expand Up @@ -672,7 +670,7 @@ pub fn app<'a>(
.takes_value(true)
.global(true)
.value_name("COMPUTE-UNIT-LIMIT")
.validator(is_parsable::<u32>)
.value_parser(clap::value_parser!(u32))
.help(COMPUTE_UNIT_LIMIT_ARG.help)
)
.arg(
Expand All @@ -681,7 +679,7 @@ pub fn app<'a>(
.takes_value(true)
.global(true)
.value_name("COMPUTE-UNIT-PRICE")
.validator(is_parsable::<u64>)
.value_parser(clap::value_parser!(u64))
.help(COMPUTE_UNIT_PRICE_ARG.help)
)
.bench_subcommand()
Expand Down
10 changes: 2 additions & 8 deletions token/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,10 @@ impl<'a> Config<'a> {
.flatten()
.copied();

let compute_unit_price = matches
.try_get_one::<u64>(COMPUTE_UNIT_PRICE_ARG.name)
.ok()
.flatten()
.copied();
let compute_unit_price = matches.get_one::<u64>(COMPUTE_UNIT_PRICE_ARG.name).copied();

let compute_unit_limit = matches
.try_get_one::<u32>(COMPUTE_UNIT_PRICE_ARG.name)
.ok()
.flatten()
.get_one::<u32>(COMPUTE_UNIT_LIMIT_ARG.name)
.copied()
.map(ComputeUnitLimit::Static)
.unwrap_or_else(|| {
Expand Down

0 comments on commit 4c65024

Please sign in to comment.