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    #[command(flatten)]
35    pub build: BuildOpts,
36
37    #[command(flatten)]
38    pub evm: EvmArgs,
39}
40
41/// Chisel binary subcommands
42#[derive(Debug, Subcommand)]
43pub enum ChiselSubcommand {
44    /// List all cached sessions.
45    List,
46
47    /// Load a cached session.
48    Load {
49        /// The ID of the session to load.
50        id: String,
51    },
52
53    /// View the source of a cached session.
54    View {
55        /// The ID of the session to load.
56        id: String,
57    },
58
59    /// Clear all cached chisel sessions from the cache directory.
60    ClearCache,
61
62    /// Simple evaluation of a command without entering the REPL.
63    Eval {
64        /// The command to be evaluated.
65        command: String,
66    },
67}