Skip to content

Commit

Permalink
Merge pull request #89 from pamburus/feature/config
Browse files Browse the repository at this point in the history
new: added support for `HL_CONFIG` environment variable
  • Loading branch information
pamburus authored Oct 11, 2023
2 parents 55ee1d4 + b977788 commit 2c46c16
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 3 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ pub struct Settings {

impl Settings {
pub fn load(app_dirs: &AppDirs) -> Result<Self, Error> {
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()?)
}
Expand Down

0 comments on commit 2c46c16

Please sign in to comment.