aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2024-03-15 22:17:41 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2024-03-15 22:17:41 +0100
commit6b935f8206c0c303a172284ff580cacf46e706f8 (patch)
tree5124759e9ae88f13c46769288d287c5af17acd1e
parent44e7b4de4073e6dc25681bb2fa6977bf5869689a (diff)
Conditional build + better errorrust
-rw-r--r--build.rs6
-rw-r--r--src/main.rs16
2 files changed, 22 insertions, 0 deletions
diff --git a/build.rs b/build.rs
new file mode 100644
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");
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index a611926..d3b3334 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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();