revme/
cmd.rs

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