| Crates.io | parenv-derive |
| lib.rs | parenv-derive |
| version | 0.1.10 |
| created_at | 2024-11-14 18:12:48.051999+00 |
| updated_at | 2026-01-25 16:21:31.458292+00 |
| description | Macro implementation of #[derive(Environment)] |
| homepage | |
| repository | https://github.com/frectonz/parenv |
| max_upload_size | |
| id | 1448156 |
| size | 20,966 |
parenvEnvironment 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(default = "value")] on the field.#[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,
/// The bird (with default)
#[parenv(default = "10")]
bird: u8,
}
fn main() {
let env = Env::parse();
dbg!(env.cat, env.dog, env.file, env.bird);
}