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
use self::commands::{
addr2line, build, clean, completions, deploy, init, json_abi, parse_bytecode, plugins, run,
test, update,
};
use addr2line::Command as Addr2LineCommand;
use anyhow::{anyhow, Result};
pub use build::Command as BuildCommand;
use clap::Parser;
pub use clean::Command as CleanCommand;
pub use completions::Command as CompletionsCommand;
pub use deploy::Command as DeployCommand;
pub use init::Command as InitCommand;
pub use json_abi::Command as JsonAbiCommand;
use parse_bytecode::Command as ParseBytecodeCommand;
pub use plugins::Command as PluginsCommand;
pub use run::Command as RunCommand;
use test::Command as TestCommand;
pub use update::Command as UpdateCommand;
mod commands;
mod plugin;
#[derive(Debug, Parser)]
#[clap(name = "forc", about = "Fuel Orchestrator", version)]
struct Opt {
#[clap(subcommand)]
command: Forc,
}
#[derive(Debug, Parser)]
enum Forc {
#[clap(name = "addr2line")]
Addr2Line(Addr2LineCommand),
#[clap(visible_alias = "b")]
Build(BuildCommand),
Clean(CleanCommand),
Completions(CompletionsCommand),
Deploy(DeployCommand),
Init(InitCommand),
ParseBytecode(ParseBytecodeCommand),
Run(RunCommand),
#[clap(visible_alias = "t")]
Test(TestCommand),
Update(UpdateCommand),
JsonAbi(JsonAbiCommand),
Plugins(PluginsCommand),
#[clap(external_subcommand)]
Plugin(Vec<String>),
}
pub async fn run_cli() -> Result<()> {
let opt = Opt::parse();
match opt.command {
Forc::Addr2Line(command) => addr2line::exec(command),
Forc::Build(command) => build::exec(command),
Forc::Clean(command) => clean::exec(command),
Forc::Completions(command) => completions::exec(command),
Forc::Deploy(command) => deploy::exec(command).await,
Forc::Init(command) => init::exec(command),
Forc::ParseBytecode(command) => parse_bytecode::exec(command),
Forc::Plugins(command) => plugins::exec(command),
Forc::Run(command) => run::exec(command).await,
Forc::Test(command) => test::exec(command),
Forc::Update(command) => update::exec(command).await,
Forc::JsonAbi(command) => json_abi::exec(command),
Forc::Plugin(args) => {
let output = plugin::execute_external_subcommand(args)?;
let code = output
.status
.code()
.ok_or_else(|| anyhow!("plugin exit status unknown"))?;
std::process::exit(code);
}
}
}