From af9b7b9ec6dd9dcb969fdf05485a4779ca7a1608 Mon Sep 17 00:00:00 2001 From: Alexander Shishenko Date: Wed, 18 Dec 2024 04:20:08 +0300 Subject: [PATCH] Resolve paths in notificox relative to current directory --- Cargo.lock | 49 ------------------------------------------- notificox/Cargo.toml | 1 - notificox/src/main.rs | 12 ++--------- 3 files changed, 2 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14b288b..ee994d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -850,27 +850,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "directories" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - [[package]] name = "displaydoc" version = "0.2.5" @@ -1822,16 +1801,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.6.0", - "libc", -] - [[package]] name = "libsqlite3-sys" version = "0.30.1" @@ -2322,7 +2291,6 @@ name = "notificox" version = "0.1.0" dependencies = [ "clap", - "directories", "dotenvy", "flume", "json5", @@ -2472,12 +2440,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "ordered-float" version = "3.9.2" @@ -2916,17 +2878,6 @@ dependencies = [ "bitflags 2.6.0", ] -[[package]] -name = "redox_users" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" -dependencies = [ - "getrandom", - "libredox", - "thiserror 1.0.69", -] - [[package]] name = "regex" version = "1.11.1" diff --git a/notificox/Cargo.toml b/notificox/Cargo.toml index 4e00b51..703cf49 100644 --- a/notificox/Cargo.toml +++ b/notificox/Cargo.toml @@ -21,4 +21,3 @@ url = { workspace = true } reqwest = { workspace = true } tracing-subscriber = "0.3.19" tracing = "0.1.41" -directories = "5.0.1" diff --git a/notificox/src/main.rs b/notificox/src/main.rs index 34b1e8c..c6039e5 100644 --- a/notificox/src/main.rs +++ b/notificox/src/main.rs @@ -19,7 +19,7 @@ use notifico_transports::all_transports; use serde_json::json; use std::path::PathBuf; use std::str::FromStr; -use std::sync::{Arc, OnceLock}; +use std::sync::Arc; use tokio::task::JoinSet; use tracing::{debug, info}; use tracing_subscriber::layer::SubscriberExt; @@ -31,8 +31,6 @@ use uuid::Uuid; const SINGLETON_CREDENTIAL_NAME: &str = "default"; const SINGLETON_EVENT_NAME: &str = "default"; -static DEFAULT_TEMPLATE_DIR: OnceLock = OnceLock::new(); - #[derive(Parser, Debug)] struct Cli { #[command(subcommand)] @@ -58,7 +56,7 @@ enum Command { /// Can be used multiple times to send multiple messages with different templates. #[arg(short, long)] template: Vec, - #[arg(long, default_value_os_t = DEFAULT_TEMPLATE_DIR.get().unwrap().clone(), env = "NOTIFICO_TEMPLATE_DIR")] + #[arg(long, default_value_os_t = std::env::current_dir().unwrap().clone(), env = "NOTIFICO_TEMPLATE_DIR")] template_dir: PathBuf, /// Attachment file(s) to be attached to the notification. /// These attachments will be attached will be attached to the first message sent. @@ -84,12 +82,6 @@ enum Command { async fn main() { let _ = dotenvy::dotenv(); - let project_dirs = directories::ProjectDirs::from("tech", "Notifico", "Notifico").unwrap(); - - DEFAULT_TEMPLATE_DIR - .set(project_dirs.data_dir().join("templates")) - .unwrap(); - if std::env::var("RUST_LOG").is_err() { std::env::set_var("RUST_LOG", "notificox=info,notifico_core=info,warn"); }