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 ///
56 /// Credentials come from this invocation. Supply --fork-url to restore a forked session.
57 Load {
58 /// The ID of the session to load.
59 id: String,
60 },
61
62 /// View the source of a cached session without restoring RPC credentials or compiling it.
63 View {
64 /// The ID of the session to load.
65 id: String,
66 },
67
68 /// Clear all cached chisel sessions from the cache directory.
69 ClearCache,
70
71 /// Simple evaluation of a command without entering the REPL.
72 Eval {
73 /// The command to be evaluated.
74 command: String,
75 },
76}