| Crates.io | env_applier |
| lib.rs | env_applier |
| version | 1.1.2 |
| created_at | 2020-03-22 16:25:18.265139+00 |
| updated_at | 2025-01-09 19:05:50.734118+00 |
| description | Apply environment variables on an object |
| homepage | |
| repository | https://github.com/jmfiaschi/env_applier |
| max_upload_size | |
| id | 221461 |
| size | 58,791 |
env_applier is a Rust crate that applies environment variables to placeholders in a string, making configuration handling simple and flexible.
Add the following line to your Cargo.toml:
[dependencies]
env_applier = "x.y.z" # Replace with the latest version
extern crate env_applier;
use env_applier::*;
fn main() -> () {
let config = r#"{"test":"{{ HOME }}"}"#.to_string().apply();
println!("My new config : {:?}", config);
}
In this example, {{ HOME }} is replaced with the value of the HOME environment variable.
extern crate env_applier;
use env_applier::*;
fn main() -> () {
let config = r#"{"test":"{{ HOME }}"}"#.to_string().apply_with_prefix("MY_PREFIX");
println!("My new config : {:?}", config);
}
When using apply_with_prefix, only environment variables prefixed with MY_PREFIX will be considered.
Contributions are welcome!
To contribute:
For major changes, please open an issue first to discuss your proposal.
Please ensure that tests are added or updated as appropriate.
Licensed under either of the following, at your option: