Override config/data paths

Without this the config is saved to $HOME/.config/core/config.json5
This commit is contained in:
2Shirt 2025-01-19 16:44:53 -08:00
parent 14a8ea7429
commit e26a83299c
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 9 additions and 6 deletions

View file

@ -52,14 +52,15 @@ pub struct Config {
pub styles: Styles, pub styles: Styles,
} }
pub static PROJECT_NAME: &'static str = "DEJA-VU";
lazy_static! { lazy_static! {
pub static ref PROJECT_NAME: String = env!("CARGO_CRATE_NAME").to_uppercase().to_string(); //pub static ref PROJECT_NAME: String = env!("CARGO_PKG_NAME").to_uppercase().to_string();
pub static ref DATA_FOLDER: Option<PathBuf> = pub static ref DATA_FOLDER: Option<PathBuf> =
env::var(format!("{}_DATA", PROJECT_NAME.clone())) env::var(format!("{}_DATA", PROJECT_NAME))
.ok() .ok()
.map(PathBuf::from); .map(PathBuf::from);
pub static ref CONFIG_FOLDER: Option<PathBuf> = pub static ref CONFIG_FOLDER: Option<PathBuf> =
env::var(format!("{}_CONFIG", PROJECT_NAME.clone())) env::var(format!("{}_CONFIG", PROJECT_NAME))
.ok() .ok()
.map(PathBuf::from); .map(PathBuf::from);
} }
@ -142,7 +143,8 @@ pub fn get_config_dir() -> PathBuf {
} }
fn project_directory() -> Option<ProjectDirs> { fn project_directory() -> Option<ProjectDirs> {
ProjectDirs::from("com", "Deja-vu", env!("CARGO_PKG_NAME")) ProjectDirs::from("com", "Deja-vu", "deja-vu")
//ProjectDirs::from("com", "Deja-vu", env!("CARGO_PKG_NAME"))
} }
#[derive(Clone, Debug, Default, Deref, DerefMut)] #[derive(Clone, Debug, Default, Deref, DerefMut)]

View file

@ -20,8 +20,9 @@ use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use crate::config; use crate::config;
lazy_static::lazy_static! { lazy_static::lazy_static! {
pub static ref LOG_ENV: String = format!("{}_LOG_LEVEL", config::PROJECT_NAME.clone()); pub static ref LOG_ENV: String = format!("{}_LOG_LEVEL", config::PROJECT_NAME);
pub static ref LOG_FILE: String = format!("{}.log", env!("CARGO_PKG_NAME")); pub static ref LOG_FILE: String = format!("{}.log", config::PROJECT_NAME);
//pub static ref LOG_FILE: String = format!("{}.log", env!("CARGO_PKG_NAME"));
} }
pub fn init() -> Result<()> { pub fn init() -> Result<()> {