blob: b1aecf62d9c33f02960ec0ce65336743c268d890 (
plain) (
blame)
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
|
use std::env;
use std::ffi::OsString;
use std::path::PathBuf;
use std::process::{self, Command};
fn main() {
exec();
}
fn exec() {
fn target_exe_path() -> PathBuf {
let mut path = env::current_exe().expect("Fail to read current_exe");
path.pop();
let target_name = if cfg!(target_os = "windows") {
"mingling-cli.exe"
} else {
"mingling-cli"
};
path.push(target_name);
path
}
let mut args: Vec<OsString> = env::args_os().collect();
let pass_args = if args.len() > 1 {
args.split_off(1)
} else {
vec![]
};
let target = target_exe_path();
let status = Command::new(&target)
.args(&pass_args)
.status()
.unwrap_or_else(|_| {
process::exit(1);
});
match status.code() {
Some(code) => process::exit(code),
None => {
process::exit(1);
}
}
}
|