reth_optimism_cli/commands/
mod.rs
1use crate::chainspec::OpChainSpecParser;
2use clap::Subcommand;
3use import::ImportOpCommand;
4use import_receipts::ImportReceiptsOpCommand;
5use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
6use reth_cli::chainspec::ChainSpecParser;
7use reth_cli_commands::{
8 config_cmd, db, dump_genesis, init_cmd,
9 node::{self, NoArgs},
10 p2p, prune, recover, stage,
11};
12use std::{fmt, sync::Arc};
13
14pub mod import;
15pub mod import_receipts;
16pub mod init_state;
17
18#[cfg(feature = "dev")]
19pub mod test_vectors;
20
21#[derive(Debug, Subcommand)]
23#[expect(clippy::large_enum_variant)]
24pub enum Commands<Spec: ChainSpecParser = OpChainSpecParser, Ext: clap::Args + fmt::Debug = NoArgs>
25{
26 #[command(name = "node")]
28 Node(Box<node::NodeCommand<Spec, Ext>>),
29 #[command(name = "init")]
31 Init(init_cmd::InitCommand<Spec>),
32 #[command(name = "init-state")]
34 InitState(init_state::InitStateCommandOp<Spec>),
35 #[command(name = "import-op")]
37 ImportOp(ImportOpCommand<Spec>),
38 #[command(name = "import-receipts-op")]
40 ImportReceiptsOp(ImportReceiptsOpCommand<Spec>),
41 DumpGenesis(dump_genesis::DumpGenesisCommand<Spec>),
43 #[command(name = "db")]
45 Db(db::Command<Spec>),
46 #[command(name = "stage")]
48 Stage(Box<stage::Command<Spec>>),
49 #[command(name = "p2p")]
51 P2P(p2p::Command<Spec>),
52 #[command(name = "config")]
54 Config(config_cmd::Command),
55 #[command(name = "recover")]
57 Recover(recover::Command<Spec>),
58 #[command(name = "prune")]
60 Prune(prune::PruneCommand<Spec>),
61 #[cfg(feature = "dev")]
63 #[command(name = "test-vectors")]
64 TestVectors(test_vectors::Command),
65}
66
67impl<
68 C: ChainSpecParser<ChainSpec: EthChainSpec + Hardforks + EthereumHardforks>,
69 Ext: clap::Args + fmt::Debug,
70 > Commands<C, Ext>
71{
72 pub fn chain_spec(&self) -> Option<&Arc<C::ChainSpec>> {
74 match self {
75 Self::Node(cmd) => cmd.chain_spec(),
76 Self::Init(cmd) => cmd.chain_spec(),
77 Self::InitState(cmd) => cmd.chain_spec(),
78 Self::DumpGenesis(cmd) => cmd.chain_spec(),
79 Self::Db(cmd) => cmd.chain_spec(),
80 Self::Stage(cmd) => cmd.chain_spec(),
81 Self::P2P(cmd) => cmd.chain_spec(),
82 Self::Config(_) => None,
83 Self::Recover(cmd) => cmd.chain_spec(),
84 Self::Prune(cmd) => cmd.chain_spec(),
85 Self::ImportOp(cmd) => cmd.chain_spec(),
86 Self::ImportReceiptsOp(cmd) => cmd.chain_spec(),
87 #[cfg(feature = "dev")]
88 Self::TestVectors(_) => None,
89 }
90 }
91}