revme/
cmd.rs

1pub mod bench;
2pub mod blockchaintest;
3pub mod bytecode;
4pub mod evmrunner;
5pub mod statetest;
6
7use clap::Parser;
8
9#[derive(Parser, Debug)]
10#[command(infer_subcommands = true)]
11#[allow(clippy::large_enum_variant)]
12pub enum MainCmd {
13    /// Execute Ethereum state tests.
14    Statetest(statetest::Cmd),
15    /// Execute Ethereum state tests.
16    Stest(statetest::Cmd),
17    /// Run arbitrary EVM bytecode.
18    Evm(evmrunner::Cmd),
19    /// Print the structure of an EVM bytecode.
20    Bytecode(bytecode::Cmd),
21    /// Run bench from specified list.
22    Bench(bench::Cmd),
23    /// Execute Ethereum blockchain tests.
24    Blockchaintest(blockchaintest::Cmd),
25    /// Execute Ethereum blockchain tests.
26    Btest(blockchaintest::Cmd),
27}
28
29#[derive(Debug, thiserror::Error)]
30pub enum Error {
31    #[error(transparent)]
32    Statetest(#[from] statetest::Error),
33    #[error(transparent)]
34    Blockchaintest(#[from] blockchaintest::Error),
35    #[error(transparent)]
36    EvmRunnerErrors(#[from] evmrunner::Errors),
37    #[error("Custom error: {0}")]
38    Custom(&'static str),
39}
40
41impl MainCmd {
42    pub fn run(&self) -> Result<(), Error> {
43        match self {
44            Self::Statetest(cmd) | Self::Stest(cmd) => cmd.run()?,
45            Self::Evm(cmd) => cmd.run()?,
46            Self::Bytecode(cmd) => {
47                cmd.run()?;
48            }
49            Self::Bench(cmd) => {
50                cmd.run();
51            }
52            Self::Blockchaintest(cmd) | Self::Btest(cmd) => cmd.run()?,
53        }
54        Ok(())
55    }
56}