Skip to content
Parse environment variables by defining a struct
Rust
Branch: master
Clone or download
Latest commit b6f6237 Sep 1, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
envopt-derive Remove empty test module Aug 31, 2019
examples Initial implementation Aug 31, 2019
src Don't run example Aug 31, 2019
.gitignore Initial implementation Aug 31, 2019
.travis.yml Initial implementation Aug 31, 2019
Cargo.toml Initial implementation Aug 31, 2019
README.md Initial implementation Aug 31, 2019
README.tpl Initial implementation Aug 31, 2019

README.md

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());
}
You can’t perform that action at this time.