diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c3f59e..8e7ff3b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
- recognize panic location in test - Fix #208
- lines to ignore can be specified as a set of regular expressions in a `ignored_lines` field either in the job or at the top of the prefs or bacon.toml - Fix #223
- `toggle-backtrace` accepts an optional level: `toggle-backtrace(1)` or `toggle-backtrace(full)` - Experimental - Fix #210
+- configuration can be passed in `BACON_PREFS` and `BACON_CONFIG` env vars - Fix #76
### v2.21.0 - 2024/09/14
diff --git a/src/cli.rs b/src/cli.rs
index e2b5f4d..483ad9e 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -73,6 +73,10 @@ pub fn run() -> anyhow::Result<()> {
}
}
+ if let Some(config) = Config::from_env("BACON_PREFS")? {
+ settings.apply_config(&config);
+ }
+
let location = MissionLocation::new(&args)?;
info!("mission location: {:#?}", &location);
@@ -102,6 +106,10 @@ pub fn run() -> anyhow::Result<()> {
settings.apply_config(&config);
}
+ if let Some(config) = Config::from_env("BACON_CONFIG")? {
+ settings.apply_config(&config);
+ }
+
// args are applied after prefs, and package config so that they can override them
settings.apply_args(&args);
diff --git a/src/config.rs b/src/config.rs
index b00dfaa..e5f46e3 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -10,7 +10,7 @@ use {
},
};
-/// A configuration item which may be stored either as `bacon.toml`
+/// A configuration item which may be stored in various places, eg as `bacon.toml`
/// along a `Cargo.toml` file or as `prefs.toml` in the xdg config directory.
///
/// Leaf values are options (and not Default) so that they don't
@@ -70,6 +70,27 @@ impl Config {
}
Ok(conf)
}
+ pub fn from_env(env_var_name: &str) -> Result