env_variable/env_variable.rs
1//! Consume a named argument with fallback to environment variable
2
3use bpaf::*;
4
5#[allow(dead_code)]
6#[derive(Clone, Debug)]
7struct Opts {
8 pub key: String,
9}
10
11pub fn main() {
12 let key = long("key")
13 .env("ACCESS_KEY")
14 .help("access key to use")
15 .argument::<String>("KEY");
16
17 let opts = construct!(Opts { key }).to_options().run();
18
19 println!("{:?}", opts);
20}