aboutsummaryrefslogtreecommitdiff
path: root/mingling_cli
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_cli')
-rw-r--r--mingling_cli/Cargo.toml10
-rw-r--r--mingling_cli/help/help.txt0
-rw-r--r--mingling_cli/src/bin/wrapper.rs47
3 files changed, 57 insertions, 0 deletions
diff --git a/mingling_cli/Cargo.toml b/mingling_cli/Cargo.toml
index 5b36c6b..98833ff 100644
--- a/mingling_cli/Cargo.toml
+++ b/mingling_cli/Cargo.toml
@@ -13,6 +13,10 @@ categories = ["command-line-interface"]
[[bin]]
name = "mling"
+path = "src/bin/wrapper.rs"
+
+[[bin]]
+name = "mingling-cli"
path = "src/main.rs"
[dependencies.mingling]
@@ -57,4 +61,10 @@ serde_json = "1.0.151"
# Code gen
just_template = "0.2.0"
+[profile.release]
+opt-level = "z"
+lto = true
+codegen-units = 1
+strip = true
+
[workspace]
diff --git a/mingling_cli/help/help.txt b/mingling_cli/help/help.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/mingling_cli/help/help.txt
diff --git a/mingling_cli/src/bin/wrapper.rs b/mingling_cli/src/bin/wrapper.rs
new file mode 100644
index 0000000..b1aecf6
--- /dev/null
+++ b/mingling_cli/src/bin/wrapper.rs
@@ -0,0 +1,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);
+ }
+ }
+}