crates.io documentation MIT License

nested-env-parser

Nested Env Parser is a crate for getting the final value of a string with nested environment variables.

installation

Install using cargo:

no_run,ignore cargo install nested-env-parser

Usage

On Unix

```rust use clap::Parser; use nestedenvparser::Env;

[derive(Clone, Debug, Parser)]

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);

} ```

On Windows

```rust use clap::Parser; use nestedenvparser::Env;

[derive(Clone, Debug, Parser)]

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