envopt

Crates.ioenvopt
lib.rsenvopt
version0.0.0
sourcesrc
created_at2019-08-31 20:41:21.493812
updated_at2019-08-31 20:41:21.493812
descriptionParse environment variables by defining a struct.
homepagehttps://github.com/zoranzaric/envopt
repositoryhttps://github.com/zoranzaric/envopt.git
max_upload_size
id161210
size6,776
Zoran Zaric (zoranzaric)

documentation

README

envopt

Crates.io Documentation License

Parse environment variables by defining a struct.

Example

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());
}
Commit count: 4

cargo fmt