Crates.io | envopt |
lib.rs | envopt |
version | 0.0.0 |
source | src |
created_at | 2019-08-31 20:41:21.493812 |
updated_at | 2019-08-31 20:41:21.493812 |
description | Parse environment variables by defining a struct. |
homepage | https://github.com/zoranzaric/envopt |
repository | https://github.com/zoranzaric/envopt.git |
max_upload_size | |
id | 161210 |
size | 6,776 |
Parse environment variables by defining a struct.
use envopt::EnvOpt;
#[derive(EnvOpt)]
pub enum EnvOpts {
#[envopt(name = "FOO")]
Foo,
#[envopt(name = "BAR", default = "default-bar")]
Bar,
}
pub fn main() {
EnvOpts::validate_or_exit();
println!("FOO: {}", EnvOpts::Foo.value_or_exit());
println!("BAR: {}", EnvOpts::Bar.value_or_exit());
}