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
use std::ffi::OsStr;
use std::process::Command;
use crate::configuration::ImporterConfiguration;
pub fn are_dependencies_callable(config: &ImporterConfiguration) -> bool {
let mut result = true;
for command in [
&config.curl,
&config.osmconvert,
&config.unzip,
&config.gunzip,
]
.iter()
{
println!("- Testing if {} is callable", command);
if !is_program_callable(command) {
println!("Failed to run {}", command);
result = false;
}
}
return result;
}
fn is_program_callable<S: AsRef<OsStr>>(name: S) -> bool {
let output = Command::new(name)
.arg("-h")
.output();
output.is_ok()
}