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
pub(crate) mod cargo_plugin_installer;
mod crate_installer;
pub(crate) mod rustup_component_installer;
#[cfg(test)]
#[path = "./mod_test.rs"]
mod mod_test;
use crate::command;
use crate::types::{InstallCrate, Task};
pub(crate) fn install(task_config: &Task) {
let validate = !task_config.is_force();
let toolchain = match task_config.toolchain {
Some(ref value) => Some(value.to_string()),
None => None,
};
match task_config.install_crate {
Some(ref install_crate_info) => match install_crate_info {
InstallCrate::Value(ref crate_name) => {
let cargo_command = match task_config.args {
Some(ref args) => &args[0],
None => {
error!("Missing cargo command to invoke.");
panic!("Missing cargo command to invoke.");
}
};
cargo_plugin_installer::install_crate(
&toolchain,
cargo_command,
crate_name,
&task_config.install_crate_args,
validate,
);
}
InstallCrate::CrateInfo(ref install_info) => crate_installer::install(
&toolchain,
install_info,
&task_config.install_crate_args,
validate,
),
InstallCrate::RustupComponentInfo(ref install_info) => {
rustup_component_installer::install(&toolchain, install_info, validate);
}
},
None => {
match task_config.install_script {
Some(ref script) => {
command::run_script(
&script,
task_config.script_runner.clone(),
&vec![],
validate,
);
()
}
None => {
match task_config.command {
Some(ref command) => {
if command == "cargo" {
match task_config.args {
Some(ref args) => {
let mut crate_name = "cargo-".to_string();
crate_name = crate_name + &args[0];
cargo_plugin_installer::install_crate(
&toolchain,
&args[0],
&crate_name,
&task_config.install_crate_args,
validate,
);
}
None => debug!("No installation script defined."),
}
}
}
None => debug!("No installation script defined."),
}
}
}
}
}
}