chisel/
opts.rs

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