Clean up argument parsing (#5290)

automerge
This commit is contained in:
Michael Vines 2019-07-26 10:37:03 -07:00 committed by Grimes
parent dab7de7496
commit 0180246680
1 changed files with 20 additions and 14 deletions

View File

@ -44,14 +44,21 @@ fn main() {
.long("identity") .long("identity")
.value_name("PATH") .value_name("PATH")
.takes_value(true) .takes_value(true)
.help("File containing an identity (keypair)"), .help("File containing the identity keypair for the validator"),
) )
.arg( .arg(
Arg::with_name("voting_keypair") Arg::with_name("voting_keypair")
.long("voting-keypair") .long("voting-keypair")
.value_name("PATH") .value_name("PATH")
.takes_value(true) .takes_value(true)
.help("File containing the authorized voting keypair"), .help("File containing the authorized voting keypair. Default is an ephemeral keypair"),
)
.arg(
Arg::with_name("vote_account")
.long("vote-account")
.value_name("PUBKEY")
.takes_value(true)
.help("Public key of the vote account to vote with. Default is the public key of the voting keypair"),
) )
.arg( .arg(
Arg::with_name("storage_keypair") Arg::with_name("storage_keypair")
@ -59,7 +66,7 @@ fn main() {
.value_name("PATH") .value_name("PATH")
.takes_value(true) .takes_value(true)
.required(true) .required(true)
.help("File containing the storage account keypair"), .help("File containing the storage account keypair. Default is an ephemeral keypair"),
) )
.arg( .arg(
Arg::with_name("init_complete_file") Arg::with_name("init_complete_file")
@ -112,23 +119,21 @@ fn main() {
.help("Enable the JSON RPC 'fullnodeExit' API. Only enable in a debug environment"), .help("Enable the JSON RPC 'fullnodeExit' API. Only enable in a debug environment"),
) )
.arg( .arg(
Arg::with_name("rpc_drone_address") Arg::with_name("rpc_drone_addr")
.long("rpc-drone-address") .long("rpc-drone-address")
.value_name("HOST:PORT") .value_name("HOST:PORT")
.takes_value(true) .takes_value(true)
.help("Enable the JSON RPC 'requestAirdrop' API with this drone address."), .help("Enable the JSON RPC 'requestAirdrop' API with this drone address."),
) )
.arg( .arg(
Arg::with_name("signer") Arg::with_name("signer_addr")
.short("s") .long("vote-signer-address")
.long("signer")
.value_name("HOST:PORT") .value_name("HOST:PORT")
.takes_value(true) .takes_value(true)
.help("Rendezvous with the vote signer at this RPC end point"), .help("Rendezvous with the vote signer at this RPC end point"),
) )
.arg( .arg(
Arg::with_name("accounts") Arg::with_name("accounts")
.short("a")
.long("accounts") .long("accounts")
.value_name("PATHS") .value_name("PATHS")
.takes_value(true) .takes_value(true)
@ -198,10 +203,10 @@ fn main() {
Keypair::new() Keypair::new()
}; };
let staking_account = matches let vote_account = matches
.value_of("staking_account") .value_of("vote_account")
.map_or(voting_keypair.pubkey(), |pubkey| { .map_or(voting_keypair.pubkey(), |pubkey| {
pubkey.parse().expect("failed to parse staking_account") pubkey.parse().expect("failed to parse vote_account")
}); });
let ledger_path = matches.value_of("ledger").unwrap(); let ledger_path = matches.value_of("ledger").unwrap();
@ -213,7 +218,7 @@ fn main() {
if matches.is_present("enable_rpc_exit") { if matches.is_present("enable_rpc_exit") {
validator_config.rpc_config.enable_fullnode_exit = true; validator_config.rpc_config.enable_fullnode_exit = true;
} }
validator_config.rpc_config.drone_addr = matches.value_of("rpc_drone_address").map(|address| { validator_config.rpc_config.drone_addr = matches.value_of("rpc_drone_addr").map(|address| {
solana_netutil::parse_host_port(address).expect("failed to parse drone address") solana_netutil::parse_host_port(address).expect("failed to parse drone address")
}); });
@ -248,7 +253,8 @@ fn main() {
ContactInfo::new_gossip_entry_point(&entrypoint_addr) ContactInfo::new_gossip_entry_point(&entrypoint_addr)
}); });
let (_signer_service, _signer_addr) = if let Some(signer_addr) = matches.value_of("signer") { let (_signer_service, _signer_addr) = if let Some(signer_addr) = matches.value_of("signer_addr")
{
( (
None, None,
signer_addr.to_string().parse().expect("Signer IP Address"), signer_addr.to_string().parse().expect("Signer IP Address"),
@ -279,7 +285,7 @@ fn main() {
node, node,
&keypair, &keypair,
ledger_path, ledger_path,
&staking_account, &vote_account,
&Arc::new(voting_keypair), &Arc::new(voting_keypair),
&Arc::new(storage_keypair), &Arc::new(storage_keypair),
cluster_entrypoint.as_ref(), cluster_entrypoint.as_ref(),