Skip to content

Commit

Permalink
fix(op-reth): --chain help message
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Sep 2, 2024
1 parent fcab695 commit 3962f29
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions bin/reth/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! CLI definition and entrypoint to executable

use crate::{
args::{utils::chain_help, LogArgs},
args::LogArgs,
commands::debug_cmd,
version::{LONG_VERSION, SHORT_VERSION},
};
Expand Down Expand Up @@ -45,7 +45,7 @@ pub struct Cli<C: ChainSpecParser = DefaultChainSpecParser, Ext: clap::Args + fm
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
long_help = C::help_messge(),
default_value = C::SUPPORTED_CHAINS[0],
value_parser = C::parser(),
global = true,
Expand Down
5 changes: 5 additions & 0 deletions crates/cli/cli/src/chainspec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ pub trait ChainSpecParser: Clone + Send + Sync + 'static {
fn parser() -> impl TypedValueParser<Value = Arc<Self::ChainSpec>> {
Parser(std::marker::PhantomData::<Self>)
}

/// Produces a help message for the chain spec argument.
fn help_messge() -> String {
format!("The chain this node is running.\nPossible values are either a built-in chain or the path to a chain specification file.\n\nBuilt-in chains:\n {}", Self::SUPPORTED_CHAINS.join(", "))
}
}
4 changes: 2 additions & 2 deletions crates/cli/commands/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use reth_db_common::init::init_genesis;
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
use reth_evm::noop::NoopBlockExecutorProvider;
use reth_node_core::{
args::{utils::chain_help, DatabaseArgs, DatadirArgs},
args::{DatabaseArgs, DatadirArgs},
dirs::{ChainPath, DataDirPath},
};
use reth_primitives::B256;
Expand Down Expand Up @@ -38,7 +38,7 @@ pub struct EnvironmentArgs<C: ChainSpecParser> {
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
long_help = C::help_messge(),
default_value = C::SUPPORTED_CHAINS[0],
value_parser = C::parser()
)]
Expand Down
3 changes: 1 addition & 2 deletions crates/cli/commands/src/dump_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::sync::Arc;
use clap::Parser;
use reth_chainspec::ChainSpec;
use reth_cli::chainspec::ChainSpecParser;
use reth_node_core::args::utils::chain_help;

/// Dumps genesis block JSON configuration to stdout
#[derive(Debug, Parser)]
Expand All @@ -15,7 +14,7 @@ pub struct DumpGenesisCommand<C: ChainSpecParser> {
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
long_help = C::help_messge(),
default_value = C::SUPPORTED_CHAINS[0],
value_parser = C::parser()
)]
Expand Down
7 changes: 3 additions & 4 deletions crates/cli/commands/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use reth_db::{init_db, DatabaseEnv};
use reth_node_builder::{NodeBuilder, WithLaunchContext};
use reth_node_core::{
args::{
utils::{chain_help, DefaultChainSpecParser},
DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs, PayloadBuilderArgs,
PruningArgs, RpcServerArgs, TxPoolArgs,
utils::DefaultChainSpecParser, DatabaseArgs, DatadirArgs, DebugArgs, DevArgs, NetworkArgs,
PayloadBuilderArgs, PruningArgs, RpcServerArgs, TxPoolArgs,
},
node_config::NodeConfig,
version,
Expand All @@ -35,7 +34,7 @@ pub struct NodeCommand<
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
long_help = C::help_messge(),
default_value = C::SUPPORTED_CHAINS[0],
default_value_if("dev", "true", "dev"),
value_parser = C::parser(),
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/commands/src/p2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use reth_config::Config;
use reth_network::{BlockDownloaderProvider, NetworkConfigBuilder};
use reth_network_p2p::bodies::client::BodiesClient;
use reth_node_core::{
args::{utils::chain_help, DatabaseArgs, DatadirArgs, NetworkArgs},
args::{DatabaseArgs, DatadirArgs, NetworkArgs},
utils::get_single_header,
};
use reth_primitives::BlockHashOrNumber;
Expand All @@ -31,7 +31,7 @@ pub struct Command<C: ChainSpecParser> {
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
long_help = C::help_messge(),
default_value = C::SUPPORTED_CHAINS[0],
value_parser = C::parser()
)]
Expand Down
5 changes: 0 additions & 5 deletions crates/node/core/src/args/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ pub const SUPPORTED_CHAINS: &[&str] =
/// Chains supported by reth. First value should be used as the default.
pub const SUPPORTED_CHAINS: &[&str] = &["mainnet", "sepolia", "holesky", "dev"];

/// The help info for the --chain flag
pub fn chain_help() -> String {
format!("The chain this node is running.\nPossible values are either a built-in chain or the path to a chain specification file.\n\nBuilt-in chains:\n {}", SUPPORTED_CHAINS.join(", "))
}

/// Clap value parser for [`ChainSpec`]s.
///
/// The value parser matches either a known chain, the path
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use reth_db::DatabaseEnv;
use reth_evm_optimism::OpExecutorProvider;
use reth_node_builder::{NodeBuilder, WithLaunchContext};
use reth_node_core::{
args::{utils::chain_help, LogArgs},
args::LogArgs,
version::{LONG_VERSION, SHORT_VERSION},
};
use reth_tracing::FileWorkerGuard;
Expand All @@ -65,7 +65,7 @@ pub struct Cli<Ext: clap::Args + fmt::Debug = NoArgs> {
#[arg(
long,
value_name = "CHAIN_OR_PATH",
long_help = chain_help(),
long_help = OpChainSpecParser::help_messge(),
default_value = OpChainSpecParser::SUPPORTED_CHAINS[0],
value_parser = OpChainSpecParser::parser(),
global = true,
Expand Down

0 comments on commit 3962f29

Please sign in to comment.