diff --git a/Cargo.lock b/Cargo.lock index 0d750b7378..f58a1a4230 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "alloy-json-abi" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28ecae8b5315daecd0075084eb47f4374b3037777346ca52fc8d9c327693f02" +checksum = "9996daf962fd0a90d3c93b388033228865953b92de7bb1959b891d78750a4091" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -184,9 +184,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb865df835f851b367ae439d6c82b117ded971628c8888b24fed411a290e38a" +checksum = "411aff151f2a73124ee473708e82ed51b2535f68928b6a1caa8bc1246ae6f7cd" dependencies = [ "alloy-rlp", "arbitrary", @@ -210,9 +210,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1376948df782ffee83a54cac4b2aba14134edd997229a3db97da0a606586eb5c" +checksum = "f2d2a195caa6707f5ce13905794865765afc6d9ea92c3a56e3a973c168d703bc" dependencies = [ "alloy-chains", "alloy-consensus", @@ -332,9 +332,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2dc5201ca0018afb7a3e0cd8bd15f7ca6aca924333b5f3bb87463b41d0c4ef2" +checksum = "0458ccb02a564228fcd76efb8eb5a520521a8347becde37b402afec9a1b83859" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -346,13 +346,13 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "155f63dc6945885aa4532601800201fddfaa3b20901fda8e8c2570327242fe0e" +checksum = "2bc65475025fc1e84bf86fc840f04f63fcccdcf3cf12053c99918e4054dfbc69" dependencies = [ "alloy-sol-macro-input", "const-hex", - "heck 0.5.0", + "heck", "indexmap", "proc-macro-error2", "proc-macro2", @@ -364,13 +364,13 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847700aa9cb59d3c7b290b2d05976cd8d76b64d73bb63116a9533132d995586b" +checksum = "6ed10f0715a0b69fde3236ff3b9ae5f6f7c97db5a387747100070d3016b9266b" dependencies = [ "const-hex", "dunce", - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.70", @@ -379,9 +379,9 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6b5d462d4520bd9ed70d8364c6280aeff13baa46ea26be1ddd33538dbbe6ac" +checksum = "3edae8ea1de519ccba896b6834dec874230f72fe695ff3c9c118e90ec7cff783" dependencies = [ "serde", "winnow 0.6.18", @@ -389,9 +389,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83665e5607725a7a1aab3cb0dea708f4a05e70776954ec7f0a9461439175c957" +checksum = "1eb88e4da0a1b697ed6a9f811fdba223cf4d5c21410804fd1707836af73a462b" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -441,12 +441,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] -name = "ansi_term" -version = "0.12.1" +name = "anstream" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ - "winapi", + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", ] [[package]] @@ -455,11 +461,39 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" -version = "1.0.87" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" +checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356" [[package]] name = "arbitrary" @@ -650,17 +684,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "aurora-engine-modexp" version = "1.1.0" @@ -903,21 +926,6 @@ dependencies = [ "half", ] -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags 1.3.2", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] - [[package]] name = "clap" version = "4.5.9" @@ -925,6 +933,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] @@ -933,8 +942,22 @@ version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ + "anstream", "anstyle", "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.70", ] [[package]] @@ -943,6 +966,12 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "console" version = "0.15.8" @@ -1009,7 +1038,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.9", + "clap", "criterion-plot", "is-terminal", "itertools 0.10.5", @@ -1802,30 +1831,12 @@ dependencies = [ "fxhash", ] -[[package]] -name = "heck" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.9" @@ -2133,11 +2144,17 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -2316,7 +2333,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", "wasi", "windows-sys 0.52.0", @@ -2436,7 +2453,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.9", + "hermit-abi", "libc", ] @@ -2836,30 +2853,6 @@ dependencies = [ "toml_edit", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -3249,6 +3242,7 @@ name = "revme" version = "0.10.1" dependencies = [ "alloy-rlp", + "clap", "hash-db", "hashbrown", "hex", @@ -3259,7 +3253,6 @@ dependencies = [ "revm", "serde", "serde_json", - "structopt", "thiserror", "triehash", "walkdir", @@ -3609,9 +3602,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.29.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" dependencies = [ "rand", "secp256k1-sys", @@ -3894,33 +3887,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] -name = "structopt" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" -dependencies = [ - "clap 2.34.0", - "lazy_static", - "structopt-derive", -] - -[[package]] -name = "structopt-derive" -version = "0.4.18" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" -dependencies = [ - "heck 0.3.3", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -3937,7 +3906,7 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "rustversion", @@ -3987,9 +3956,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1e1355d44af21638c8e05d45097db6cb5ec2aa3e970c51cb2901605cf3344fa" +checksum = "4b95156f8b577cb59dc0b1df15c6f29a10afc5f8a7ac9786b0b5c68c19149278" dependencies = [ "paste", "proc-macro2", @@ -4072,15 +4041,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.63" @@ -4447,12 +4407,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-segmentation" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" - [[package]] name = "unicode-width" version = "0.1.13" @@ -4494,6 +4448,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "valuable" version = "0.1.0" @@ -4506,12 +4466,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" diff --git a/bins/revme/Cargo.toml b/bins/revme/Cargo.toml index 798673b830..b8f02f90d2 100644 --- a/bins/revme/Cargo.toml +++ b/bins/revme/Cargo.toml @@ -28,7 +28,7 @@ alloy-rlp = { version = "0.3", default-features = false, features = [ ] } serde = { version = "1.0", features = ["derive", "rc"] } serde_json = { version = "1.0", features = ["preserve_order"] } -structopt = "0.3" +clap = { version = "4", features = ["derive"] } thiserror = "1.0" triehash = "0.8" walkdir = "2.5" diff --git a/bins/revme/src/cmd.rs b/bins/revme/src/cmd.rs index 97ea618aee..a36a637a6e 100644 --- a/bins/revme/src/cmd.rs +++ b/bins/revme/src/cmd.rs @@ -3,21 +3,19 @@ pub mod eofvalidation; pub mod evmrunner; pub mod statetest; -use structopt::{clap::AppSettings, StructOpt}; +use clap::Parser; -#[derive(StructOpt, Debug)] -#[structopt(setting = AppSettings::InferSubcommands)] +#[derive(Parser, Debug)] +#[command(infer_subcommands = true)] #[allow(clippy::large_enum_variant)] pub enum MainCmd { - #[structopt(about = "Execute Ethereum state tests")] + /// Execute Ethereum state tests. Statetest(statetest::Cmd), - #[structopt(about = "Execute eof validation tests")] + /// Execute eof validation tests. EofValidation(eofvalidation::Cmd), - #[structopt( - about = "Evm runner command allows running arbitrary evm bytecode.\nBytecode can be provided from cli or from file with --path option." - )] + /// Run arbitrary EVM bytecode. Evm(evmrunner::Cmd), - #[structopt(alias = "bc", about = "Prints the opcodes of an hex Bytecodes.")] + /// Print the structure of an EVM bytecode. Bytecode(bytecode::Cmd), } diff --git a/bins/revme/src/cmd/bytecode.rs b/bins/revme/src/cmd/bytecode.rs index f46ebc264c..a0843a9492 100644 --- a/bins/revme/src/cmd/bytecode.rs +++ b/bins/revme/src/cmd/bytecode.rs @@ -1,3 +1,4 @@ +use clap::Parser; use revm::{ interpreter::{ analysis::{validate_eof_inner, CodeType, EofError}, @@ -6,21 +7,20 @@ use revm::{ primitives::{Bytes, Eof, MAX_INITCODE_SIZE}, }; use std::io; -use structopt::StructOpt; -/// Statetest command -#[derive(StructOpt, Debug)] +/// `bytecode` subcommand. +#[derive(Parser, Debug)] pub struct Cmd { /// Is EOF code in INITCODE mode. - #[structopt(long)] + #[arg(long)] eof_initcode: bool, /// Is EOF code in RUNTIME mode. - #[structopt(long)] + #[arg(long)] eof_runtime: bool, /// Bytecode in hex format. If bytes start with 0xFE it will be interpreted as a EOF. /// Otherwise, it will be interpreted as a EOF bytecode. /// If not provided, it will operate in interactive EOF validation mode. - #[structopt()] + #[arg()] bytes: Option, } diff --git a/bins/revme/src/cmd/eofvalidation.rs b/bins/revme/src/cmd/eofvalidation.rs index 6d1d39fd4f..1badad7e77 100644 --- a/bins/revme/src/cmd/eofvalidation.rs +++ b/bins/revme/src/cmd/eofvalidation.rs @@ -3,24 +3,24 @@ mod test_suite; pub use test_suite::{PragueTestResult, TestResult, TestSuite, TestUnit, TestVector}; use crate::{cmd::Error, dir_utils::find_all_json_tests}; +use clap::Parser; use revm::interpreter::analysis::{validate_raw_eof_inner, CodeType, EofError}; use std::collections::BTreeMap; use std::path::{Path, PathBuf}; -use structopt::StructOpt; -/// Eof validation command. -#[derive(StructOpt, Debug)] +/// `eof-validation` subcommand. +#[derive(Parser, Debug)] pub struct Cmd { - /// Input path to eof validation test - #[structopt(required = true)] - path: Vec, + /// Input paths to EOF validation tests. + #[arg(required = true, num_args = 1..)] + paths: Vec, } impl Cmd { /// Run statetest command. pub fn run(&self) -> Result<(), Error> { // check if path exists. - for path in &self.path { + for path in &self.paths { if !path.exists() { return Err(Error::Custom("The specified path does not exist")); } diff --git a/bins/revme/src/cmd/evmrunner.rs b/bins/revme/src/cmd/evmrunner.rs index 3065280213..381b153de4 100644 --- a/bins/revme/src/cmd/evmrunner.rs +++ b/bins/revme/src/cmd/evmrunner.rs @@ -1,3 +1,4 @@ +use clap::Parser; use revm::{ db::BenchmarkDB, inspector_handle_register, @@ -9,9 +10,6 @@ use std::io::Error as IoError; use std::path::PathBuf; use std::time::Duration; use std::{borrow::Cow, fs}; -use structopt::StructOpt; - -extern crate alloc; #[derive(Debug, thiserror::Error)] pub enum Errors { @@ -31,26 +29,26 @@ pub enum Errors { /// Evm runner command allows running arbitrary evm bytecode. /// Bytecode can be provided from cli or from file with --path option. -#[derive(StructOpt, Debug)] +#[derive(Parser, Debug)] pub struct Cmd { - /// Bytecode to be executed. - #[structopt(default_value = "")] - bytecode: String, - /// Path to file containing the evm bytecode. - /// Overrides the bytecode option. - #[structopt(long)] + /// Hex-encoded EVM bytecode to be executed. + #[arg(required_unless_present = "path")] + bytecode: Option, + /// Path to a file containing the hex-encoded EVM bytecode to be executed. + /// Overrides the positional `bytecode` argument. + #[arg(long)] path: Option, /// Run in benchmarking mode. - #[structopt(long)] + #[arg(long)] bench: bool, - /// Input bytes. - #[structopt(long, default_value = "")] + /// Hex-encoded input/calldata bytes. + #[arg(long, default_value = "")] input: String, /// Print the state. - #[structopt(long)] + #[arg(long)] state: bool, /// Print the trace. - #[structopt(long)] + #[arg(long)] trace: bool, } @@ -64,9 +62,11 @@ impl Cmd { if !path.exists() { return Err(Errors::PathNotExists); } - fs::read_to_string(path)?.to_owned().into() + fs::read_to_string(path)?.into() + } else if let Some(bytecode) = &self.bytecode { + bytecode.as_str().into() } else { - self.bytecode.as_str().into() + unreachable!() }; let bytecode = hex::decode(bytecode_str.trim()).map_err(|_| Errors::InvalidBytecode)?; diff --git a/bins/revme/src/cmd/statetest.rs b/bins/revme/src/cmd/statetest.rs index cc082cb0d4..2b62a43430 100644 --- a/bins/revme/src/cmd/statetest.rs +++ b/bins/revme/src/cmd/statetest.rs @@ -5,38 +5,39 @@ pub mod utils; pub use runner::TestError as Error; +use clap::Parser; use runner::{find_all_json_tests, run, TestError}; use std::path::PathBuf; -use structopt::StructOpt; -/// Statetest command -#[derive(StructOpt, Debug)] +/// `statetest` subcommand. +#[derive(Parser, Debug)] pub struct Cmd { /// Path to folder or file containing the tests. If multiple paths are specified /// they will be run in sequence. /// /// Folders will be searched recursively for files with the extension `.json`. - #[structopt(required = true)] - path: Vec, + #[clap(required = true, num_args = 1..)] + paths: Vec, /// Run tests in a single thread. - #[structopt(short = "s", long)] + #[clap(short = 's', long)] single_thread: bool, /// Output results in JSON format. /// It will stop second run of evm on failure. - #[structopt(long)] + #[clap(long)] json: bool, - /// Output outcome in JSON format. If json is true, this is implied. - /// It will stop second run of evm on failure. - #[structopt(short = "o", long)] + /// Output outcome in JSON format. If `--json` is true, this is implied. + /// It will stop second run of EVM on failure. + #[clap(short = 'o', long)] json_outcome: bool, - #[structopt(long, alias = "no-fail-fast")] + /// Keep going after a test failure. + #[clap(long, alias = "no-fail-fast")] keep_going: bool, } impl Cmd { /// Run statetest command. pub fn run(&self) -> Result<(), TestError> { - for path in &self.path { + for path in &self.paths { println!("\nRunning tests in {}...", path.display()); let test_files = find_all_json_tests(path); run( diff --git a/bins/revme/src/main.rs b/bins/revme/src/main.rs index 4662057476..992e9d248e 100644 --- a/bins/revme/src/main.rs +++ b/bins/revme/src/main.rs @@ -1,11 +1,6 @@ +use clap::Parser; use revme::cmd::{Error, MainCmd}; -use structopt::StructOpt; -pub fn main() -> Result<(), Error> { - let cmd = MainCmd::from_args(); - if let Err(e) = cmd.run() { - println!("{:?}", e); - return Err(e); - } - Ok(()) +fn main() -> Result<(), Error> { + MainCmd::parse().run().inspect_err(|e| eprintln!("{e:?}")) }