chisel/
opts.rs

1use clap::{Parser, Subcommand};
2use foundry_cli::opts::{BuildOpts, EvmArgs, GlobalArgs};
3use foundry_common::version::{LONG_VERSION, SHORT_VERSION};
4use std::path::PathBuf;
5
6foundry_config::impl_figment_convert!(Chisel, build, evm);
7
8/// Fast, utilitarian, and verbose Solidity REPL.
9#[derive(Debug, Parser)]
10#[command(name = "chisel", version = SHORT_VERSION, long_version = LONG_VERSION)]
11pub struct Chisel {
12    /// Include the global arguments.
13    #[command(flatten)]
14    pub global: GlobalArgs,
15
16    #[command(subcommand)]
17    pub cmd: Option<ChiselSubcommand>,
18
19    /// Path to a directory containing Solidity files to import, or path to a single Solidity file.
20    ///
21    /// These files will be evaluated before the top-level of the
22    /// REPL, therefore functioning as a prelude
23    #[arg(long, help_heading = "REPL options")]
24    pub prelude: Option<PathBuf>,
25
26    /// Disable the default `Vm` import.
27    #[arg(long, help_heading = "REPL options", long_help = format!(
28        "Disable the default `Vm` import.\n\n\
29         The import is disabled by default if the Solc version is less than {}.",
30        crate::source::MIN_VM_VERSION
31    ))]
32    pub no_vm: bool,
33
34    /// Enable viaIR with minimum optimization
35    ///
36    /// This can fix most of the "stack too deep" errors while resulting a
37    /// relatively accurate source map.
38    #[arg(long, help_heading = "REPL options")]
39    pub ir_minimum: bool,
40
41    #[command(flatten)]
42    pub build: BuildOpts,
43
44    #[command(flatten)]
45    pub evm: EvmArgs,
46}
47
48/// Chisel binary subcommands
49#[derive(Debug, Subcommand)]
50pub enum ChiselSubcommand {
51    /// List all cached sessions.
52    List,
53
54    /// Load a cached session.
55    Load {
56        /// The ID of the session to load.
57        id: String,
58    },
59
60    /// View the source of a cached session.
61    View {
62        /// The ID of the session to load.
63        id: String,
64    },
65
66    /// Clear all cached chisel sessions from the cache directory.
67    ClearCache,
68
69    /// Simple evaluation of a command without entering the REPL.
70    Eval {
71        /// The command to be evaluated.
72        command: String,
73    },
74}