Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 87a679f

Browse files
committed
repalce is_parsable with parser
1 parent 288ded3 commit 87a679f

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

token/cli/src/bench.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) async fn bench_process_command(
3434
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
3535
.unwrap()
3636
.unwrap();
37-
let n = value_t_or_exit!(arg_matches, "n", usize);
37+
let n = *arg_matches.get_one::<usize>("n").unwrap();
3838

3939
let (owner_signer, owner) =
4040
config.signer_or_default(arg_matches, "owner", wallet_manager);
@@ -46,7 +46,7 @@ pub(crate) async fn bench_process_command(
4646
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
4747
.unwrap()
4848
.unwrap();
49-
let n = value_t_or_exit!(arg_matches, "n", usize);
49+
let n = *arg_matches.get_one::<usize>("n").unwrap();
5050
let (owner_signer, owner) =
5151
config.signer_or_default(arg_matches, "owner", wallet_manager);
5252
signers.push(owner_signer);
@@ -57,7 +57,7 @@ pub(crate) async fn bench_process_command(
5757
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
5858
.unwrap()
5959
.unwrap();
60-
let n = value_t_or_exit!(arg_matches, "n", usize);
60+
let n = *arg_matches.get_one::<usize>("n").unwrap();
6161
let ui_amount = *arg_matches.get_one::<Amount>("amount").unwrap();
6262
let (owner_signer, owner) =
6363
config.signer_or_default(arg_matches, "owner", wallet_manager);
@@ -72,7 +72,7 @@ pub(crate) async fn bench_process_command(
7272
let token = pubkey_of_signer(arg_matches, "token", wallet_manager)
7373
.unwrap()
7474
.unwrap();
75-
let n = value_t_or_exit!(arg_matches, "n", usize);
75+
let n = *arg_matches.get_one::<usize>("n").unwrap();
7676
let ui_amount = *arg_matches.get_one::<Amount>("amount").unwrap();
7777
let (owner_signer, owner) =
7878
config.signer_or_default(arg_matches, "owner", wallet_manager);

token/cli/src/clap_app.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ use {
55
solana_clap_v3_utils::{
66
fee_payer::fee_payer_arg,
77
input_parsers::Amount,
8-
input_validators::{
9-
is_parsable, is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer,
10-
},
8+
input_validators::{is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer},
119
memo::memo_arg,
1210
nonce::*,
1311
offline::{self, *},
@@ -471,7 +469,7 @@ impl BenchSubCommand for App<'_> {
471469
)
472470
.arg(
473471
Arg::with_name("n")
474-
.validator(is_parsable::<usize>)
472+
.value_parser(clap::value_parser!(usize))
475473
.value_name("N")
476474
.takes_value(true)
477475
.index(2)
@@ -494,7 +492,7 @@ impl BenchSubCommand for App<'_> {
494492
)
495493
.arg(
496494
Arg::with_name("n")
497-
.validator(is_parsable::<usize>)
495+
.value_parser(clap::value_parser!(usize))
498496
.value_name("N")
499497
.takes_value(true)
500498
.index(2)
@@ -517,7 +515,7 @@ impl BenchSubCommand for App<'_> {
517515
)
518516
.arg(
519517
Arg::with_name("n")
520-
.validator(is_parsable::<usize>)
518+
.value_parser(clap::value_parser!(usize))
521519
.value_name("N")
522520
.takes_value(true)
523521
.index(2)
@@ -557,7 +555,7 @@ impl BenchSubCommand for App<'_> {
557555
)
558556
.arg(
559557
Arg::with_name("n")
560-
.validator(is_parsable::<usize>)
558+
.value_parser(clap::value_parser!(usize))
561559
.value_name("N")
562560
.takes_value(true)
563561
.index(2)
@@ -670,7 +668,7 @@ pub fn app<'a>(
670668
.takes_value(true)
671669
.global(true)
672670
.value_name("COMPUTE-UNIT-LIMIT")
673-
.validator(is_parsable::<u32>)
671+
.value_parser(clap::value_parser!(u32))
674672
.help(COMPUTE_UNIT_LIMIT_ARG.help)
675673
)
676674
.arg(
@@ -679,7 +677,7 @@ pub fn app<'a>(
679677
.takes_value(true)
680678
.global(true)
681679
.value_name("COMPUTE-UNIT-PRICE")
682-
.validator(is_parsable::<u64>)
680+
.value_parser(clap::value_parser!(u64))
683681
.help(COMPUTE_UNIT_PRICE_ARG.help)
684682
)
685683
.bench_subcommand()

token/cli/src/config.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,10 @@ impl<'a> Config<'a> {
327327
.flatten()
328328
.copied();
329329

330-
let compute_unit_price = matches
331-
.try_get_one::<u64>(COMPUTE_UNIT_PRICE_ARG.name)
332-
.ok()
333-
.flatten()
334-
.copied();
330+
let compute_unit_price = matches.get_one::<u64>(COMPUTE_UNIT_PRICE_ARG.name).copied();
335331

336332
let compute_unit_limit = matches
337-
.try_get_one::<u32>(COMPUTE_UNIT_PRICE_ARG.name)
338-
.ok()
339-
.flatten()
333+
.get_one::<u32>(COMPUTE_UNIT_LIMIT_ARG.name)
340334
.copied()
341335
.map(ComputeUnitLimit::Static)
342336
.unwrap_or_else(|| {

0 commit comments

Comments
 (0)