-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
forge.rs
122 lines (119 loc) · 3.23 KB
/
forge.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
use clap::{IntoApp, Parser};
use clap_complete::generate;
use foundry_cli::{
cmd::{
forge::{cache::CacheSubcommands, watch},
Cmd,
},
handler,
opts::forge::{Opts, Subcommands},
utils,
};
fn main() -> eyre::Result<()> {
utils::load_dotenv();
handler::install()?;
utils::subscriber();
utils::enable_paint();
let opts = Opts::parse();
match opts.sub {
Subcommands::Test(cmd) => {
if cmd.is_watch() {
utils::block_on(watch::watch_test(cmd))?;
} else {
let outcome = cmd.run()?;
outcome.ensure_ok()?;
}
}
Subcommands::Script(cmd) => {
utils::block_on(cmd.run_script())?;
}
Subcommands::Coverage(cmd) => {
cmd.run()?;
}
Subcommands::Bind(cmd) => {
cmd.run()?;
}
Subcommands::Build(cmd) => {
if cmd.is_watch() {
utils::block_on(watch::watch_build(cmd))?;
} else {
cmd.run()?;
}
}
Subcommands::Debug(cmd) => {
utils::block_on(cmd.debug())?;
}
Subcommands::VerifyContract(args) => {
utils::block_on(args.run())?;
}
Subcommands::VerifyCheck(args) => {
utils::block_on(args.run())?;
}
Subcommands::Cache(cmd) => match cmd.sub {
CacheSubcommands::Clean(cmd) => {
cmd.run()?;
}
CacheSubcommands::Ls(cmd) => {
cmd.run()?;
}
},
Subcommands::Create(cmd) => {
utils::block_on(cmd.run())?;
}
Subcommands::Update(cmd) => cmd.run()?,
Subcommands::Install(cmd) => {
cmd.run()?;
}
Subcommands::Remove(cmd) => {
cmd.run()?;
}
Subcommands::Remappings(cmd) => {
cmd.run()?;
}
Subcommands::Init(cmd) => {
cmd.run()?;
}
Subcommands::Completions { shell } => {
generate(shell, &mut Opts::command(), "forge", &mut std::io::stdout())
}
Subcommands::GenerateFigSpec => clap_complete::generate(
clap_complete_fig::Fig,
&mut Opts::command(),
"forge",
&mut std::io::stdout(),
),
Subcommands::Clean { root } => {
let config = utils::load_config_with_root(root);
config.project()?.cleanup()?;
}
Subcommands::Snapshot(cmd) => {
if cmd.is_watch() {
utils::block_on(watch::watch_snapshot(cmd))?;
} else {
cmd.run()?;
}
}
Subcommands::Fmt(cmd) => {
cmd.run()?;
}
Subcommands::Config(cmd) => {
cmd.run()?;
}
Subcommands::Flatten(cmd) => {
cmd.run()?;
}
Subcommands::Inspect(cmd) => {
cmd.run()?;
}
Subcommands::UploadSelectors(args) => {
utils::block_on(args.run())?;
}
Subcommands::Tree(cmd) => {
cmd.run()?;
}
Subcommands::Geiger(cmd) => {
cmd.run()?;
}
}
Ok(())
}