Nested Env Parser is a crate for getting the final value of a string with nested environment variables.
Install using cargo:
no_run,ignore
cargo install nested-env-parser
```rust use clap::Parser; use nestedenvparser::Env;
struct Opts { #[clap(env)] valuewithenv: Env, }
fn main() { std::env::setvar("VALUE1", "Hello,"); std::env::setvar("VALUE2", "world"); std::env::setvar("VALUEWITH_ENV", "$VALUE1 ${VALUE2}!");
let opts = Opts::parse();
let value: &str = &opts.value_with_env;
assert_eq!("Hello, world!", value);
} ```
```rust use clap::Parser; use nestedenvparser::Env;
struct Opts { #[clap(env)] valuewithenv: Env, }
fn main() { std::env::setvar("VALUE1", "Hello"); std::env::setvar("VALUE2", "world"); std::env::setvar("VALUEWITH_ENV", "%VALUE1%, %VALUE2%!");
let opts = Opts::parse();
let value: &str = &opts.value_with_env;
assert_eq!("Hello, world!", value);
} ```
Current version: 1.0.0
License: MIT