Add clap.rs default for --commitment (#9859)
This commit is contained in:
parent
f37f83fd12
commit
ffbbdd46e8
|
@ -11,7 +11,8 @@ pub fn commitment_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||||
Arg::with_name(COMMITMENT_ARG.name)
|
Arg::with_name(COMMITMENT_ARG.name)
|
||||||
.long(COMMITMENT_ARG.long)
|
.long(COMMITMENT_ARG.long)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_values(&["default", "max", "recent", "root"])
|
.possible_values(&["recent", "root", "max"])
|
||||||
|
.default_value("recent")
|
||||||
.value_name("COMMITMENT_LEVEL")
|
.value_name("COMMITMENT_LEVEL")
|
||||||
.help(COMMITMENT_ARG.help)
|
.help(COMMITMENT_ARG.help)
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,14 +166,7 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
||||||
.default_value("15")
|
.default_value("15")
|
||||||
.help("Wait up to timeout seconds for transaction confirmation"),
|
.help("Wait up to timeout seconds for transaction confirmation"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(commitment_arg()),
|
||||||
Arg::with_name(COMMITMENT_ARG.name)
|
|
||||||
.long(COMMITMENT_ARG.long)
|
|
||||||
.takes_value(true)
|
|
||||||
.possible_values(&["default", "max", "recent", "root"])
|
|
||||||
.value_name("COMMITMENT_LEVEL")
|
|
||||||
.help("Wait until the transaction is confirmed at selected commitment level"),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("live-slots")
|
SubCommand::with_name("live-slots")
|
||||||
|
@ -272,8 +265,7 @@ pub fn parse_catchup(
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
) -> Result<CliCommandInfo, CliError> {
|
||||||
let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?.unwrap();
|
let node_pubkey = pubkey_of_signer(matches, "node_pubkey", wallet_manager)?.unwrap();
|
||||||
let node_json_rpc_url = value_t!(matches, "node_json_rpc_url", String).ok();
|
let node_json_rpc_url = value_t!(matches, "node_json_rpc_url", String).ok();
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
let follow = matches.is_present("follow");
|
let follow = matches.is_present("follow");
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::Catchup {
|
command: CliCommand::Catchup {
|
||||||
|
@ -299,8 +291,7 @@ pub fn parse_cluster_ping(
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
|
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::Ping {
|
command: CliCommand::Ping {
|
||||||
lamports,
|
lamports,
|
||||||
|
@ -327,8 +318,7 @@ pub fn parse_get_block_time(matches: &ArgMatches<'_>) -> Result<CliCommandInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_get_epoch_info(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_get_epoch_info(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::GetEpochInfo { commitment_config },
|
command: CliCommand::GetEpochInfo { commitment_config },
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
|
@ -336,8 +326,7 @@ pub fn parse_get_epoch_info(matches: &ArgMatches<'_>) -> Result<CliCommandInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_get_slot(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_get_slot(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::GetSlot { commitment_config },
|
command: CliCommand::GetSlot { commitment_config },
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
|
@ -345,8 +334,7 @@ pub fn parse_get_slot(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliErr
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_get_epoch(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_get_epoch(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::GetEpoch { commitment_config },
|
command: CliCommand::GetEpoch { commitment_config },
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
|
@ -354,8 +342,7 @@ pub fn parse_get_epoch(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliEr
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_total_supply(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_total_supply(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::TotalSupply { commitment_config },
|
command: CliCommand::TotalSupply { commitment_config },
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
|
@ -363,8 +350,7 @@ pub fn parse_total_supply(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Cl
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_get_transaction_count(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_get_transaction_count(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::GetTransactionCount { commitment_config },
|
command: CliCommand::GetTransactionCount { commitment_config },
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
|
@ -390,8 +376,7 @@ pub fn parse_show_stakes(
|
||||||
|
|
||||||
pub fn parse_show_validators(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_show_validators(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let use_lamports_unit = matches.is_present("lamports");
|
let use_lamports_unit = matches.is_present("lamports");
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::ShowValidators {
|
command: CliCommand::ShowValidators {
|
||||||
|
|
|
@ -315,8 +315,7 @@ pub fn parse_vote_get_account_command(
|
||||||
let vote_account_pubkey =
|
let vote_account_pubkey =
|
||||||
pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap();
|
pubkey_of_signer(matches, "vote_account_pubkey", wallet_manager)?.unwrap();
|
||||||
let use_lamports_unit = matches.is_present("lamports");
|
let use_lamports_unit = matches.is_present("lamports");
|
||||||
let commitment_config =
|
let commitment_config = commitment_of(matches, COMMITMENT_ARG.long).unwrap();
|
||||||
commitment_of(matches, COMMITMENT_ARG.long).unwrap_or_else(CommitmentConfig::recent);
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::ShowVoteAccount {
|
command: CliCommand::ShowVoteAccount {
|
||||||
pubkey: vote_account_pubkey,
|
pubkey: vote_account_pubkey,
|
||||||
|
|
Loading…
Reference in New Issue