Crates.io | nested-env-parser |
lib.rs | nested-env-parser |
version | 1.1.0 |
source | src |
created_at | 2023-05-12 05:59:51.376586 |
updated_at | 2023-05-31 16:35:13.008871 |
description | Nested Env Parser is a crate for getting the final value of a string with nested environment variables. |
homepage | |
repository | https://github.com/erritis/nested-env-parser |
max_upload_size | |
id | 862715 |
size | 9,010 |
Nested Env Parser is a crate for getting the final value of a string with nested environment variables.
Install using cargo:
cargo install nested-env-parser
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);
}
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