From ac1e110b02233ce8b459411ac31945ab0c157c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 19 Dec 2021 20:09:44 +0100 Subject: [PATCH] optional "desktop" feature --- Cargo.toml | 7 ++++++- src/main.rs | 11 +++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0c067fd..fe316d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,10 +48,15 @@ walkdir = "2" tree_magic = "0.2.3" dotenv = "0.15.0" -webbrowser = "0.5.5" xdg = "^2.1" +webbrowser = { version = "^0.5.5", optional = true } + nonempty = "0.6.0" [dev-dependencies] tempdir = "0.3.7" + +[features] +default = ["desktop"] +desktop = ["webbrowser"] \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 16b3646..10079f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,10 +152,13 @@ fn main() -> Result<()> { actix::spawn(filesystem::rescan_vault(db_pool, vault_path, job_container)); } - if !matches.is_present("NO_BROWSER") && ui_enabled { - let ui_result = webbrowser::open(&format!("http://localhost:{}", bind.port())); - if ui_result.is_err() { - warn!("Could not open UI in browser!"); + #[cfg(feature = "desktop")] + { + if !matches.is_present("NO_BROWSER") && ui_enabled { + let ui_result = webbrowser::open(&format!("http://localhost:{}", bind.port())); + if ui_result.is_err() { + warn!("Could not open UI in browser!"); + } } }