multiversx_sc_meta/cmd/
install.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
pub mod install_debugger;
mod install_scenario_go;
mod install_wasm_tools;
mod system_info;

use crate::cli::{
    InstallArgs, InstallCommand, InstallDebuggerArgs, InstallMxScenarioGoArgs, InstallWasm32Args,
    InstallWasmOptArgs,
};

use self::install_scenario_go::ScenarioGoInstaller;

pub async fn install(args: &InstallArgs) {
    let command = args
        .command
        .as_ref()
        .expect("command expected after `install`");

    match command {
        InstallCommand::All => {
            install_scenario_go(&InstallMxScenarioGoArgs::default()).await;
            install_wasm32(&InstallWasm32Args::default());
            install_wasm_opt(&InstallWasmOptArgs::default());
            install_debugger(&InstallDebuggerArgs::default()).await;
        },
        InstallCommand::MxScenarioGo(sg_args) => install_scenario_go(sg_args).await,
        InstallCommand::Wasm32(wam32_args) => install_wasm32(wam32_args),
        InstallCommand::WasmOpt(wasm_opt_args) => install_wasm_opt(wasm_opt_args),
        InstallCommand::Debugger(debugger_args) => install_debugger(debugger_args).await,
    }
}

async fn install_scenario_go(sg_args: &InstallMxScenarioGoArgs) {
    ScenarioGoInstaller::new(sg_args.tag.clone())
        .install()
        .await;
}

fn install_wasm32(_wasm32_args: &InstallWasm32Args) {
    install_wasm_tools::install_wasm32_target();
}

fn install_wasm_opt(_wasm_opt_args: &InstallWasmOptArgs) {
    install_wasm_tools::install_wasm_opt();
}

async fn install_debugger(_debugger_args: &InstallDebuggerArgs) {
    install_debugger::install_debugger(Option::None).await;
}