Skip to content

Commit

Permalink
Resolve paths in notificox relative to current directory
Browse files Browse the repository at this point in the history
  • Loading branch information
GamePad64 committed Dec 18, 2024
1 parent fb9564a commit af9b7b9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 60 deletions.
49 changes: 0 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion notificox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ url = { workspace = true }
reqwest = { workspace = true }
tracing-subscriber = "0.3.19"
tracing = "0.1.41"
directories = "5.0.1"
12 changes: 2 additions & 10 deletions notificox/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,8 +31,6 @@ use uuid::Uuid;
const SINGLETON_CREDENTIAL_NAME: &str = "default";
const SINGLETON_EVENT_NAME: &str = "default";

static DEFAULT_TEMPLATE_DIR: OnceLock<PathBuf> = OnceLock::new();

#[derive(Parser, Debug)]
struct Cli {
#[command(subcommand)]
Expand All @@ -58,7 +56,7 @@ enum Command {
/// Can be used multiple times to send multiple messages with different templates.
#[arg(short, long)]
template: Vec<String>,
#[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.
Expand All @@ -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");
}
Expand Down

0 comments on commit af9b7b9

Please sign in to comment.