Skip to content

Commit

Permalink
Add solana_clap_utils::hidden_unless_forced() (#30843)
Browse files Browse the repository at this point in the history
* Add solana_clap_utils::hidden_unless_forced()

* Use more descriptive env name

Co-authored-by: mvines <[email protected]>

---------

Co-authored-by: mvines <[email protected]>
  • Loading branch information
ryoqun and mvines authored Mar 22, 2023
1 parent ac8c31b commit 721719d
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 68 deletions.
6 changes: 4 additions & 2 deletions accounts-cluster-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use {
rand::{thread_rng, Rng},
rayon::prelude::*,
solana_account_decoder::parse_token::spl_token_pubkey,
solana_clap_utils::{input_parsers::pubkey_of, input_validators::is_url_or_moniker},
solana_clap_utils::{
hidden_unless_forced, input_parsers::pubkey_of, input_validators::is_url_or_moniker,
},
solana_cli_config::{ConfigInput, CONFIG_FILE},
solana_client::transaction_executor::TransactionExecutor,
solana_gossip::gossip_service::discover,
Expand Down Expand Up @@ -529,7 +531,7 @@ fn main() {
.long("faucet")
.takes_value(true)
.value_name("HOST:PORT")
.hidden(true)
.hidden(hidden_unless_forced())
.help("Faucet entrypoint address. Usually <ip>:9900"),
)
.arg(
Expand Down
7 changes: 5 additions & 2 deletions bench-tps/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use {
crate::spl_convert::FromOtherSolana,
clap::{crate_description, crate_name, App, Arg, ArgMatches},
solana_clap_utils::input_validators::{is_keypair, is_url, is_url_or_moniker, is_within_range},
solana_clap_utils::{
hidden_unless_forced,
input_validators::{is_keypair, is_url, is_url_or_moniker, is_within_range},
},
solana_cli_config::{ConfigInput, CONFIG_FILE},
solana_sdk::{
fee_calculator::FeeRateGovernor,
Expand Down Expand Up @@ -185,7 +188,7 @@ pub fn build_args<'a>(version: &'_ str) -> App<'a, '_> {
.long("faucet")
.value_name("HOST:PORT")
.takes_value(true)
.hidden(true)
.hidden(hidden_unless_forced())
.help("Deprecated. BenchTps no longer queries the faucet directly"),
)
.arg(
Expand Down
4 changes: 4 additions & 0 deletions clap-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ impl std::fmt::Debug for DisplayError {
}
}

pub fn hidden_unless_forced() -> bool {
std::env::var("SOLANA_NO_HIDDEN_CLI_ARGS").is_err()
}

pub mod compute_unit_price;
pub mod fee_payer;
pub mod input_parsers;
Expand Down
6 changes: 3 additions & 3 deletions cli/src/clap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
inflation::*, nonce::*, program::*, stake::*, validator_info::*, vote::*, wallet::*,
},
clap::{App, AppSettings, Arg, ArgGroup, SubCommand},
solana_clap_utils::{self, input_validators::*, keypair::*},
solana_clap_utils::{self, hidden_unless_forced, input_validators::*, keypair::*},
solana_cli_config::CONFIG_FILE,
};

Expand Down Expand Up @@ -125,7 +125,7 @@ pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> A
.takes_value(true)
.default_value(DEFAULT_RPC_TIMEOUT_SECONDS)
.global(true)
.hidden(true)
.hidden(hidden_unless_forced())
.help("Timeout value for RPC requests"),
)
.arg(
Expand All @@ -135,7 +135,7 @@ pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> A
.takes_value(true)
.default_value(DEFAULT_CONFIRM_TX_TIMEOUT_SECONDS)
.global(true)
.hidden(true)
.hidden(hidden_unless_forced())
.help("Timeout value for initial transaction status"),
)
.cluster_query_subcommands()
Expand Down
6 changes: 4 additions & 2 deletions cli/src/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use {
clap::{App, AppSettings, Arg, ArgMatches, SubCommand},
console::style,
serde::{Deserialize, Serialize},
solana_clap_utils::{fee_payer::*, input_parsers::*, input_validators::*, keypair::*},
solana_clap_utils::{
fee_payer::*, hidden_unless_forced, input_parsers::*, input_validators::*, keypair::*,
},
solana_cli_output::{cli_version::CliVersion, QuietDisplay, VerboseDisplay},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_rpc_client::rpc_client::RpcClient,
Expand Down Expand Up @@ -424,7 +426,7 @@ impl FeatureSubCommands for App<'_, '_> {
.arg(
Arg::with_name("force")
.long("yolo")
.hidden(true)
.hidden(hidden_unless_forced())
.multiple(true)
.help("Override activation sanity checks. Don't use this flag"),
)
Expand Down
6 changes: 4 additions & 2 deletions cli/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use {
log::*,
solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig},
solana_bpf_loader_program::syscalls::create_loader,
solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*},
solana_clap_utils::{
self, hidden_unless_forced, input_parsers::*, input_validators::*, keypair::*,
},
solana_cli_output::{
CliProgram, CliProgramAccountType, CliProgramAuthority, CliProgramBuffer, CliProgramId,
CliUpgradeableBuffer, CliUpgradeableBuffers, CliUpgradeableProgram,
Expand Down Expand Up @@ -134,7 +136,7 @@ impl ProgramSubCommands for App<'_, '_> {
.arg(
Arg::with_name("skip_fee_check")
.long("skip-fee-check")
.hidden(true)
.hidden(hidden_unless_forced())
.takes_value(false)
.global(true)
)
Expand Down
5 changes: 3 additions & 2 deletions cli/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use {
solana_clap_utils::{
compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
hidden_unless_forced,
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
Expand Down Expand Up @@ -267,7 +268,7 @@ impl StakeSubCommands for App<'_, '_> {
Arg::with_name("force")
.long("force")
.takes_value(false)
.hidden(true) // Don't document this argument to discourage its use
.hidden(hidden_unless_forced()) // Don't document this argument to discourage its use
.help("Override vote account sanity checks (use carefully!)")
)
.arg(
Expand Down Expand Up @@ -298,7 +299,7 @@ impl StakeSubCommands for App<'_, '_> {
Arg::with_name("force")
.long("force")
.takes_value(false)
.hidden(true) // Don't document this argument to discourage its use
.hidden(hidden_unless_forced()) // Don't document this argument to discourage its use
.help("Override vote account sanity checks (use carefully!)")
)
.arg(
Expand Down
3 changes: 2 additions & 1 deletion cli/src/validator_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
self, ValidatorInfo, MAX_LONG_FIELD_LENGTH, MAX_SHORT_FIELD_LENGTH,
},
solana_clap_utils::{
hidden_unless_forced,
input_parsers::pubkey_of,
input_validators::{is_pubkey, is_url},
keypair::DefaultSigner,
Expand Down Expand Up @@ -182,7 +183,7 @@ impl ValidatorInfoSubCommands for App<'_, '_> {
Arg::with_name("force")
.long("force")
.takes_value(false)
.hidden(true) // Don't document this argument to discourage its use
.hidden(hidden_unless_forced()) // Don't document this argument to discourage its use
.help("Override keybase username validity check"),
),
)
Expand Down
5 changes: 3 additions & 2 deletions cli/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use {
solana_clap_utils::{
compute_unit_price::{compute_unit_price_arg, COMPUTE_UNIT_PRICE_ARG},
fee_payer::*,
hidden_unless_forced,
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
Expand Down Expand Up @@ -252,15 +253,15 @@ impl WalletSubCommands for App<'_, '_> {
.value_name("SEED_STRING")
.requires("derived_address_program_id")
.validator(is_derived_address_seed)
.hidden(true)
.hidden(hidden_unless_forced())
)
.arg(
Arg::with_name("derived_address_program_id")
.long("derived-address-program-id")
.takes_value(true)
.value_name("PROGRAM_ID")
.requires("derived_address_seed")
.hidden(true)
.hidden(hidden_unless_forced())
)
.arg(
Arg::with_name("allow_unfunded_recipient")
Expand Down
3 changes: 2 additions & 1 deletion gossip/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use {
SubCommand,
},
solana_clap_utils::{
hidden_unless_forced,
input_parsers::keypair_of,
input_validators::{is_keypair_or_ask_keyword, is_port, is_pubkey},
},
Expand Down Expand Up @@ -39,7 +40,7 @@ fn parse_matches() -> ArgMatches<'static> {
.long("allow-private-addr")
.takes_value(false)
.help("Allow contacting private ip addresses")
.hidden(true),
.hidden(hidden_unless_forced()),
)
.subcommand(
SubCommand::with_name("rpc-url")
Expand Down
9 changes: 5 additions & 4 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use {
serde_json::json,
solana_account_decoder::{UiAccount, UiAccountData, UiAccountEncoding},
solana_clap_utils::{
hidden_unless_forced,
input_parsers::{cluster_type_of, pubkey_of, pubkeys_of},
input_validators::{
is_parsable, is_pow2, is_pubkey, is_pubkey_or_keypair, is_slot, is_valid_percentage,
Expand Down Expand Up @@ -1476,7 +1477,7 @@ fn main() {
.help(
"Debug option to scan all AppendVecs and verify account index refcounts prior to clean",
)
.hidden(true);
.hidden(hidden_unless_forced());
let accounts_filler_count = Arg::with_name("accounts_filler_count")
.long("accounts-filler-count")
.value_name("COUNT")
Expand Down Expand Up @@ -1523,7 +1524,7 @@ fn main() {
Arg::with_name("accounts_db_skip_initial_hash_calculation")
.long("accounts-db-skip-initial-hash-calculation")
.help("Do not verify accounts hash at startup.")
.hidden(true);
.hidden(hidden_unless_forced());
let ancient_append_vecs = Arg::with_name("accounts_db_ancient_append_vecs")
.long("accounts-db-ancient-append-vecs")
.value_name("SLOT-OFFSET")
Expand All @@ -1532,11 +1533,11 @@ fn main() {
.help(
"AppendVecs that are older than (slots_per_epoch - SLOT-OFFSET) are squashed together.",
)
.hidden(true);
.hidden(hidden_unless_forced());
let halt_at_slot_store_hash_raw_data = Arg::with_name("halt_at_slot_store_hash_raw_data")
.long("halt-at-slot-store-hash-raw-data")
.help("After halting at slot, run an accounts hash calculation and store the raw hash data for debugging.")
.hidden(true);
.hidden(hidden_unless_forced());
let verify_index_arg = Arg::with_name("verify_accounts_index")
.long("verify-accounts-index")
.takes_value(false)
Expand Down
Loading

0 comments on commit 721719d

Please sign in to comment.