Crates.io | parenv-derive |
lib.rs | parenv-derive |
version | 0.1.5 |
source | src |
created_at | 2024-11-14 18:12:48.051999 |
updated_at | 2024-11-24 12:49:39.364004 |
description | Macro implementation of #[derive(Environment)] |
homepage | |
repository | https://github.com/frectonz/parenv |
max_upload_size | |
id | 1448156 |
size | 15,458 |
parenv
Environment variable parser with a clap style derive macro and elm style error reporting.
cargo add parenv
Here are some important features you should know about.
parenv
relies on the FromStr
trait to parse environment variables into the specified type.Option
.#[parenv(prefix = "ENV_")]
on your struct.#[parenv(suffix = "_ARG")]
on your struct.use std::{net::SocketAddr, path::PathBuf};
use parenv::Environment;
#[derive(Debug, Environment)]
#[parenv(prefix = "ENV_", suffix = "_ARG")]
struct Env {
/// The cat
cat: Option<u8>,
/// The dog
dog: SocketAddr,
/// The file
file: PathBuf,
}
fn main() {
let env = Env::parse();
dbg!(env.cat, env.dog, env.file);
}