nested-env-parser 1.1.0

Nested Env Parser is a crate for getting the final value of a string with nested environment variables.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 3 items with examples
  • Size
  • Source code size: 16.77 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.72 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • zyrakq/nested-env-parser
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zeritiq

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:

cargo install nested-env-parser

Usage

On Unix

use clap::Parser;
use nested_env_parser::Env;

#[derive(Clone, Debug, Parser)]
struct Opts {
    #[clap(env)]
    value_with_env: Env,
}

fn main() {
    std::env::set_var("VALUE1", "Hello,");
    std::env::set_var("VALUE2", "world");
    std::env::set_var("VALUE_WITH_ENV", "$VALUE1 ${VALUE2}!");

    let opts = Opts::parse();

    assert_eq!("Hello, world!", &opts.value_with_env);
}

On Windows

use clap::Parser;
use nested_env_parser::Env;

#[derive(Clone, Debug, Parser)]
struct Opts {
    #[clap(env)]
    value_with_env: Env,
}

fn main() {
    std::env::set_var("VALUE1", "Hello");
    std::env::set_var("VALUE2", "world");
    std::env::set_var("VALUE_WITH_ENV", "%VALUE1%, %VALUE2%!");

    let opts = Opts::parse();

    assert_eq!("Hello, world!", &opts.value_with_env);
}

Current version: 1.1.0

License: MIT