From b977788306ab3f0ce391696542875b1739dc404e Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Tue, 10 Oct 2023 21:58:28 +0200 Subject: [PATCH] new: added support for `HL_CONFIG` environment variable --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/settings.rs | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3fb694bc..2d5cbd7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -739,7 +739,7 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hl" -version = "0.20.0-beta.14.7.1" +version = "0.20.0-beta.14.8" dependencies = [ "atoi", "bincode", diff --git a/Cargo.toml b/Cargo.toml index db2898ed..cf23b716 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ categories = ["command-line-utilities"] description = "Utility for viewing json-formatted log files." keywords = ["cli", "human", "log"] name = "hl" -version = "0.20.0-beta.14.7.1" +version = "0.20.0-beta.14.8" edition = "2021" build = "build.rs" diff --git a/src/settings.rs b/src/settings.rs index a1adc039..b01444fb 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -32,11 +32,12 @@ pub struct Settings { impl Settings { pub fn load(app_dirs: &AppDirs) -> Result { - let filename = app_dirs.config_dir.join("config.yaml"); + let filename = std::env::var("HL_CONFIG") + .unwrap_or_else(|_| app_dirs.config_dir.join("config.yaml").to_string_lossy().to_string()); Ok(Config::builder() .add_source(File::from_str(DEFAULT_SETTINGS, FileFormat::Yaml)) - .add_source(File::with_name(&filename.to_string_lossy()).required(false)) + .add_source(File::with_name(&filename).required(false)) .build()? .try_deserialize()?) }