Skip to main content

anvil/
opts.rs

1use crate::cmd::NodeArgs;
2use clap::{Parser, Subcommand};
3use foundry_cli::opts::GlobalArgs;
4use foundry_common::version::{LONG_VERSION, SHORT_VERSION};
5
6/// A fast local Ethereum development node
7///
8/// Examples:
9/// - anvil (start a local node on 127.0.0.1:8545)
10/// - anvil --fork-url $RPC_URL (fork the latest state of a live network)
11/// - anvil --block-time 12 (mine a new block every 12 seconds)
12/// - anvil --state state.json (load state if it exists and dump it on exit)
13#[derive(Parser)]
14#[command(verbatim_doc_comment, name = "anvil", version = SHORT_VERSION, long_version = LONG_VERSION, next_display_order = None)]
15pub struct Anvil {
16    /// Include the global arguments.
17    #[command(flatten)]
18    pub global: GlobalArgs,
19
20    #[command(flatten)]
21    pub node: NodeArgs,
22
23    #[command(subcommand)]
24    pub cmd: Option<AnvilSubcommand>,
25}
26
27#[derive(Subcommand)]
28pub enum AnvilSubcommand {
29    /// Generate shell completions script.
30    #[command(visible_alias = "com")]
31    Completions {
32        #[arg(value_enum)]
33        shell: foundry_cli::clap::Shell,
34    },
35}