diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc67320..39f0112 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
- new `exports` structure in configuration. New `analysis` export bound by default to `ctrl-e`. The old syntax defining locations export is still supported but won't appear in documentations anymore.
- recognize panic location in test - Fix #208
- `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 353834c..640ccce 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 80857c1..36a063c 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
@@ -66,6 +66,27 @@ impl Config {
}
Ok(conf)
}
+ pub fn from_env(env_var_name: &str) -> Result