]> git.r.bdr.sh - rbdr/lyricli/commitdiff
Conditional build + better error
authorRuben Beltran del Rio <redacted>
Fri, 15 Mar 2024 21:17:41 +0000 (22:17 +0100)
committerRuben Beltran del Rio <redacted>
Fri, 15 Mar 2024 21:17:41 +0000 (22:17 +0100)
build.rs [new file with mode: 0644]
src/main.rs

diff --git a/build.rs b/build.rs
new file mode 100644 (file)
index 0000000..85b3d43
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,6 @@
+fn main() {
+    let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
+    if target_os == "macos" {
+        println!("cargo:rustc-link-lib=framework=ScriptingBridge");
+    }
+}
index a6119266f25581e98b17ff7530816455372b4d2e..d3b3334e44228b1999309a5b9ae9568b0059cf35 100644 (file)
@@ -46,6 +46,22 @@ pub struct Track {
 
 #[tokio::main]
 async fn main() -> Result<()> {
+    let result = run().await;
+
+    if cfg!(debug_assertions) {
+        result
+    } else {
+        match result {
+            Ok(_) => Ok(()),
+            Err(e) => {
+                eprintln!("Error: {}", e);
+                std::process::exit(1);
+            }
+        }
+    }
+}
+
+async fn run() -> Result<()> {
     let mut configuration = Configuration::new();
     let arguments = Arguments::parse();