Skip to content

Commit

Permalink
solana-cli: format strings (#34288)
Browse files Browse the repository at this point in the history
* Format strings in solana-cli

* Restore some wallet.rs strings that were better before

* Fixup vote.rs string

* Fixup stake.rs string

* Fixup program.rs strings

* Fixup some address_lookup_table.rs strings

* Fixup clap_app.rs string

* Clarify validator_info help

* Fixup cluster_query.rs
  • Loading branch information
CriesofCarrots authored Dec 1, 2023
1 parent 7c4e723 commit 68928bb
Show file tree
Hide file tree
Showing 12 changed files with 939 additions and 693 deletions.
128 changes: 80 additions & 48 deletions cli/src/address_lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.takes_value(true)
.validator(is_pubkey)
.help(
"Lookup table authority address [default: the default configured keypair]. \
WARNING: Cannot be used for creating a lookup table for a cluster running v1.11
or earlier which requires the authority to sign for lookup table creation.",
)
"Lookup table authority address \
[default: the default configured keypair]. \
WARNING: Cannot be used for creating a lookup table for \
a cluster running v1.11 or earlier which requires the \
authority to sign for lookup table creation.",
),
)
.arg(
Arg::with_name("authority_signer")
Expand All @@ -92,16 +94,22 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.takes_value(true)
.conflicts_with("authority")
.validator(is_valid_signer)
.help("Lookup table authority keypair [default: the default configured keypair].")
.help(
"Lookup table authority keypair \
[default: the default configured keypair].",
),
)
.arg(
Arg::with_name("payer")
.long("payer")
.value_name("PAYER_SIGNER")
.takes_value(true)
.validator(is_valid_signer)
.help("Account that will pay rent fees for the created lookup table [default: the default configured keypair]")
)
.help(
"Account that will pay rent fees for the created lookup table \
[default: the default configured keypair]",
),
),
)
.subcommand(
SubCommand::with_name("freeze")
Expand All @@ -113,15 +121,18 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.takes_value(true)
.required(true)
.validator(is_pubkey)
.help("Address of the lookup table")
.help("Address of the lookup table"),
)
.arg(
Arg::with_name("authority")
.long("authority")
.value_name("AUTHORITY_SIGNER")
.takes_value(true)
.validator(is_valid_signer)
.help("Lookup table authority [default: the default configured keypair]")
.help(
"Lookup table authority \
[default: the default configured keypair]",
),
)
.arg(
Arg::with_name("bypass_warning")
Expand All @@ -140,23 +151,29 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.takes_value(true)
.required(true)
.validator(is_pubkey)
.help("Address of the lookup table")
.help("Address of the lookup table"),
)
.arg(
Arg::with_name("authority")
.long("authority")
.value_name("AUTHORITY_SIGNER")
.takes_value(true)
.validator(is_valid_signer)
.help("Lookup table authority [default: the default configured keypair]")
.help(
"Lookup table authority \
[default: the default configured keypair]",
),
)
.arg(
Arg::with_name("payer")
.long("payer")
.value_name("PAYER_SIGNER")
.takes_value(true)
.validator(is_valid_signer)
.help("Account that will pay rent fees for the extended lookup table [default: the default configured keypair]")
.help(
"Account that will pay rent fees for the extended lookup \
table [default: the default configured keypair]",
),
)
.arg(
Arg::with_name("addresses")
Expand All @@ -166,8 +183,8 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.use_delimiter(true)
.required(true)
.validator(is_pubkey)
.help("Comma separated list of addresses to append")
)
.help("Comma separated list of addresses to append"),
),
)
.subcommand(
SubCommand::with_name("deactivate")
Expand All @@ -178,15 +195,18 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.value_name("LOOKUP_TABLE_ADDRESS")
.takes_value(true)
.required(true)
.help("Address of the lookup table")
.help("Address of the lookup table"),
)
.arg(
Arg::with_name("authority")
.long("authority")
.value_name("AUTHORITY_SIGNER")
.takes_value(true)
.validator(is_valid_signer)
.help("Lookup table authority [default: the default configured keypair]")
.help(
"Lookup table authority \
[default: the default configured keypair]",
),
)
.arg(
Arg::with_name("bypass_warning")
Expand All @@ -204,24 +224,30 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.value_name("LOOKUP_TABLE_ADDRESS")
.takes_value(true)
.required(true)
.help("Address of the lookup table")
.help("Address of the lookup table"),
)
.arg(
Arg::with_name("recipient")
.long("recipient")
.value_name("RECIPIENT_ADDRESS")
.takes_value(true)
.validator(is_pubkey)
.help("Address of the recipient account to deposit the closed account's lamports [default: the default configured keypair]")
.help(
"Address of the recipient account to deposit the closed \
account's lamports [default: the default configured keypair]",
),
)
.arg(
Arg::with_name("authority")
.long("authority")
.value_name("AUTHORITY_SIGNER")
.takes_value(true)
.validator(is_valid_signer)
.help("Lookup table authority [default: the default configured keypair]")
)
.help(
"Lookup table authority \
[default: the default configured keypair]",
),
),
)
.subcommand(
SubCommand::with_name("get")
Expand All @@ -231,9 +257,9 @@ impl AddressLookupTableSubCommands for App<'_, '_> {
.index(1)
.value_name("LOOKUP_TABLE_ADDRESS")
.takes_value(true)
.help("Address of the lookup table to show")
)
)
.help("Address of the lookup table to show"),
),
),
)
}
}
Expand Down Expand Up @@ -593,9 +619,9 @@ fn process_create_lookup_table(
}
}

pub const FREEZE_LOOKUP_TABLE_WARNING: &str = "WARNING! \
Once a lookup table is frozen, it can never be modified or unfrozen again. \
To proceed with freezing, rerun the `freeze` command with the `--bypass-warning` flag";
pub const FREEZE_LOOKUP_TABLE_WARNING: &str =
"WARNING! Once a lookup table is frozen, it can never be modified or unfrozen again. To \
proceed with freezing, rerun the `freeze` command with the `--bypass-warning` flag";

fn process_freeze_lookup_table(
rpc_client: &RpcClient,
Expand All @@ -613,9 +639,10 @@ fn process_freeze_lookup_table(
})?;
if !address_lookup_table::program::check_id(&lookup_table_account.owner) {
return Err(format!(
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table program",
)
.into());
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table \
program",
)
.into());
}

if !bypass_warning {
Expand Down Expand Up @@ -671,9 +698,10 @@ fn process_extend_lookup_table(
})?;
if !address_lookup_table::program::check_id(&lookup_table_account.owner) {
return Err(format!(
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table program",
)
.into());
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table \
program",
)
.into());
}

let authority_address = authority_signer.pubkey();
Expand Down Expand Up @@ -709,10 +737,10 @@ fn process_extend_lookup_table(
}
}

pub const DEACTIVATE_LOOKUP_TABLE_WARNING: &str = "WARNING! \
Once a lookup table is deactivated, it is no longer usable by transactions.
Deactivated lookup tables may only be closed and cannot be recreated at the same address. \
To proceed with deactivation, rerun the `deactivate` command with the `--bypass-warning` flag";
pub const DEACTIVATE_LOOKUP_TABLE_WARNING: &str =
"WARNING! Once a lookup table is deactivated, it is no longer usable by transactions.
Deactivated lookup tables may only be closed and cannot be recreated at the same address. To \
proceed with deactivation, rerun the `deactivate` command with the `--bypass-warning` flag";

fn process_deactivate_lookup_table(
rpc_client: &RpcClient,
Expand All @@ -730,9 +758,10 @@ fn process_deactivate_lookup_table(
})?;
if !address_lookup_table::program::check_id(&lookup_table_account.owner) {
return Err(format!(
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table program",
)
.into());
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table \
program",
)
.into());
}

if !bypass_warning {
Expand Down Expand Up @@ -783,17 +812,19 @@ fn process_close_lookup_table(
})?;
if !address_lookup_table::program::check_id(&lookup_table_account.owner) {
return Err(format!(
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table program",
)
.into());
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table \
program",
)
.into());
}

let lookup_table_account = AddressLookupTable::deserialize(&lookup_table_account.data)?;
if lookup_table_account.meta.deactivation_slot == u64::MAX {
return Err(format!(
"Lookup table account {lookup_table_pubkey} is not deactivated. Only deactivated lookup tables may be closed",
)
.into());
"Lookup table account {lookup_table_pubkey} is not deactivated. Only deactivated \
lookup tables may be closed",
)
.into());
}

let authority_address = authority_signer.pubkey();
Expand Down Expand Up @@ -836,9 +867,10 @@ fn process_show_lookup_table(
})?;
if !address_lookup_table::program::check_id(&lookup_table_account.owner) {
return Err(format!(
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table program",
)
.into());
"Lookup table account {lookup_table_pubkey} is not owned by the Address Lookup Table \
program",
)
.into());
}

let lookup_table_account = AddressLookupTable::deserialize(&lookup_table_account.data)?;
Expand Down
33 changes: 18 additions & 15 deletions cli/src/clap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> A
.validator(is_url_or_moniker)
.help(
"URL for Solana's JSON RPC or moniker (or their first letter): \
[mainnet-beta, testnet, devnet, localhost]",
[mainnet-beta, testnet, devnet, localhost]",
),
)
.arg(
Expand Down Expand Up @@ -67,16 +67,19 @@ pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> A
"processed",
"confirmed",
"finalized",
"recent", // Deprecated as of v1.5.5
"single", // Deprecated as of v1.5.5
"recent", // Deprecated as of v1.5.5
"single", // Deprecated as of v1.5.5
"singleGossip", // Deprecated as of v1.5.5
"root", // Deprecated as of v1.5.5
"max", // Deprecated as of v1.5.5
"root", // Deprecated as of v1.5.5
"max", // Deprecated as of v1.5.5
])
.value_name("COMMITMENT_LEVEL")
.hide_possible_values(true)
.global(true)
.help("Return information at the selected commitment level [possible values: processed, confirmed, finalized]"),
.help(
"Return information at the selected commitment level \
[possible values: processed, confirmed, finalized]",
),
)
.arg(
Arg::with_name("verbose")
Expand Down Expand Up @@ -207,14 +210,14 @@ pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> A
)
.subcommand(
SubCommand::with_name("completion")
.about("Generate completion scripts for various shells")
.arg(
Arg::with_name("shell")
.long("shell")
.short("s")
.takes_value(true)
.possible_values(&["bash", "fish", "zsh", "powershell", "elvish"])
.default_value("bash")
)
.about("Generate completion scripts for various shells")
.arg(
Arg::with_name("shell")
.long("shell")
.short("s")
.takes_value(true)
.possible_values(&["bash", "fish", "zsh", "powershell", "elvish"])
.default_value("bash"),
),
)
}
Loading

0 comments on commit 68928bb

Please sign in to comment.