cli review feedback

This commit is contained in:
Michael Vines 2020-09-24 13:30:38 -07:00
parent 199940d683
commit 3a2b8c5e5b
3 changed files with 17 additions and 15 deletions

View File

@ -523,11 +523,6 @@ pub fn parse_command(
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
) -> Result<CliCommandInfo, Box<dyn error::Error>> { ) -> Result<CliCommandInfo, Box<dyn error::Error>> {
let response = match matches.subcommand() { let response = match matches.subcommand() {
// Feature subcommand
("feature", Some(matches)) => {
feature_parse_subcommand(matches, default_signer, wallet_manager)
}
// Cluster Query Commands // Cluster Query Commands
("catchup", Some(matches)) => parse_catchup(matches, wallet_manager), ("catchup", Some(matches)) => parse_catchup(matches, wallet_manager),
("cluster-date", Some(_matches)) => Ok(CliCommandInfo { ("cluster-date", Some(_matches)) => Ok(CliCommandInfo {
@ -541,6 +536,9 @@ pub fn parse_command(
("create-address-with-seed", Some(matches)) => { ("create-address-with-seed", Some(matches)) => {
parse_create_address_with_seed(matches, default_signer, wallet_manager) parse_create_address_with_seed(matches, default_signer, wallet_manager)
} }
("feature", Some(matches)) => {
parse_feature_subcommand(matches, default_signer, wallet_manager)
}
("fees", Some(_matches)) => Ok(CliCommandInfo { ("fees", Some(_matches)) => Ok(CliCommandInfo {
command: CliCommand::Fees, command: CliCommand::Fees,
signers: vec![], signers: vec![],
@ -1962,9 +1960,9 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
), ),
) )
.cluster_query_subcommands() .cluster_query_subcommands()
.feature_subcommands()
.nonce_subcommands() .nonce_subcommands()
.stake_subcommands() .stake_subcommands()
.feature_subcommands()
.subcommand( .subcommand(
SubCommand::with_name("airdrop") SubCommand::with_name("airdrop")
.about("Request lamports") .about("Request lamports")

View File

@ -5,7 +5,7 @@ use crate::{
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use console::style; use console::style;
use solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*}; use solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*};
use solana_client::rpc_client::RpcClient; use solana_client::{client_error::ClientError, rpc_client::RpcClient};
use solana_remote_wallet::remote_wallet::RemoteWalletManager; use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_runtime::{ use solana_runtime::{
feature::{self, Feature}, feature::{self, Feature},
@ -35,11 +35,12 @@ impl FeatureSubCommands for App<'_, '_> {
SubCommand::with_name("status") SubCommand::with_name("status")
.about("Query runtime feature status") .about("Query runtime feature status")
.arg( .arg(
Arg::with_name("feature") Arg::with_name("features")
.value_name("ADDRESS") .value_name("ADDRESS")
.validator(is_valid_pubkey) .validator(is_valid_pubkey)
.index(1) .index(1)
.help("Feature status to query [default: "), .multiple(true)
.help("Feature status to query [default: all known features]"),
), ),
) )
.subcommand( .subcommand(
@ -50,6 +51,7 @@ impl FeatureSubCommands for App<'_, '_> {
.value_name("FEATURE_KEYPAIR") .value_name("FEATURE_KEYPAIR")
.validator(is_valid_signer) .validator(is_valid_signer)
.index(1) .index(1)
.required(true)
.help("The signer for the feature to activate"), .help("The signer for the feature to activate"),
), ),
), ),
@ -68,7 +70,7 @@ fn known_feature(feature: &Pubkey) -> Result<(), CliError> {
} }
} }
pub fn feature_parse_subcommand( pub fn parse_feature_subcommand(
matches: &ArgMatches<'_>, matches: &ArgMatches<'_>,
default_signer: &DefaultSigner, default_signer: &DefaultSigner,
wallet_manager: &mut Option<Arc<RemoteWalletManager>>, wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
@ -88,9 +90,11 @@ pub fn feature_parse_subcommand(
} }
} }
("status", Some(matches)) => { ("status", Some(matches)) => {
let mut features = if let Some(feature) = pubkey_of(matches, "feature") { let mut features = if let Some(features) = pubkeys_of(matches, "features") {
known_feature(&feature)?; for feature in &features {
vec![feature] known_feature(feature)?;
}
features
} else { } else {
FEATURE_NAMES.keys().cloned().collect() FEATURE_NAMES.keys().cloned().collect()
}; };
@ -117,7 +121,7 @@ pub fn process_feature_subcommand(
} }
// Feature activation is only allowed when 95% of the active stake is on the current feature set // Feature activation is only allowed when 95% of the active stake is on the current feature set
fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, Box<dyn std::error::Error>> { fn feature_activation_allowed(rpc_client: &RpcClient) -> Result<bool, ClientError> {
let my_feature_set = solana_version::Version::default().feature_set; let my_feature_set = solana_version::Version::default().feature_set;
let feature_set_map = rpc_client let feature_set_map = rpc_client

View File

@ -7,7 +7,7 @@ use std::{convert::TryInto, fmt};
#[macro_use] #[macro_use]
extern crate solana_sdk_macro_frozen_abi; extern crate solana_sdk_macro_frozen_abi;
// Older version structure used by 1.3.12 and earlier releases // Older version structure used earlier 1.3.x releases
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]
pub struct LegacyVersion { pub struct LegacyVersion {
major: u16, major: u16,