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

Commit ac50d8f

Browse files
committed
repalce is_parsable with parser
1 parent 06b0c1f commit ac50d8f

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

token/cli/src/bench.rs

+4-4
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

+7-9
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use {
77
solana_clap_v3_utils::{
88
fee_payer::fee_payer_arg,
99
input_parsers::Amount,
10-
input_validators::{
11-
is_parsable, is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer,
12-
},
10+
input_validators::{is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer},
1311
memo::memo_arg,
1412
nonce::*,
1513
offline::{self, *},
@@ -473,7 +471,7 @@ impl BenchSubCommand for App<'_> {
473471
)
474472
.arg(
475473
Arg::with_name("n")
476-
.validator(is_parsable::<usize>)
474+
.value_parser(clap::value_parser!(usize))
477475
.value_name("N")
478476
.takes_value(true)
479477
.index(2)
@@ -496,7 +494,7 @@ impl BenchSubCommand for App<'_> {
496494
)
497495
.arg(
498496
Arg::with_name("n")
499-
.validator(is_parsable::<usize>)
497+
.value_parser(clap::value_parser!(usize))
500498
.value_name("N")
501499
.takes_value(true)
502500
.index(2)
@@ -519,7 +517,7 @@ impl BenchSubCommand for App<'_> {
519517
)
520518
.arg(
521519
Arg::with_name("n")
522-
.validator(is_parsable::<usize>)
520+
.value_parser(clap::value_parser!(usize))
523521
.value_name("N")
524522
.takes_value(true)
525523
.index(2)
@@ -559,7 +557,7 @@ impl BenchSubCommand for App<'_> {
559557
)
560558
.arg(
561559
Arg::with_name("n")
562-
.validator(is_parsable::<usize>)
560+
.value_parser(clap::value_parser!(usize))
563561
.value_name("N")
564562
.takes_value(true)
565563
.index(2)
@@ -672,7 +670,7 @@ pub fn app<'a>(
672670
.takes_value(true)
673671
.global(true)
674672
.value_name("COMPUTE-UNIT-LIMIT")
675-
.validator(is_parsable::<u32>)
673+
.value_parser(clap::value_parser!(u32))
676674
.help(COMPUTE_UNIT_LIMIT_ARG.help)
677675
)
678676
.arg(
@@ -681,7 +679,7 @@ pub fn app<'a>(
681679
.takes_value(true)
682680
.global(true)
683681
.value_name("COMPUTE-UNIT-PRICE")
684-
.validator(is_parsable::<u64>)
682+
.value_parser(clap::value_parser!(u64))
685683
.help(COMPUTE_UNIT_PRICE_ARG.help)
686684
)
687685
.bench_subcommand()

token/cli/src/config.rs

+2-8
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_LIMIT_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)