From 4aa0db987cc48aa915d2ed534033b9e7eb03d0cb Mon Sep 17 00:00:00 2001 From: Oliver Ni Date: Sun, 14 Jul 2024 13:23:40 -0400 Subject: [PATCH] Add customizing config path --- src/config.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index a25b5a1..007a0c7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -250,7 +250,10 @@ pub fn load(path: &str) -> Result { } pub static CONFIG: LazyLock = LazyLock::new(|| { - match load("config.json") { + let config_path = var("CONFIG"); + let config_path = config_path.as_deref().unwrap_or("config.json"); + + match load(config_path) { Ok(config) => config, Err(err) => { // Avoid panicking @@ -266,9 +269,12 @@ pub async fn watch_config_changes(reload_handle: reload::Handle(reload_handle: reload::Handle