15 lines
415 B
Rust
15 lines
415 B
Rust
use crate::models::WatcherConfig;
|
|
|
|
impl WatcherConfig {
|
|
pub fn from_env() -> Result<Self, config::ConfigError> {
|
|
// Load .env file (works in both Docker and local development)
|
|
dotenvy::dotenv().ok();
|
|
|
|
let mut cfg = config::Config::builder()
|
|
.add_source(config::Environment::with_prefix("WATCHER").separator("_"))
|
|
.build()?;
|
|
|
|
cfg.try_deserialize()
|
|
}
|
|
}
|