mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Update the env var example for derive
Updates the derive example handling environment variables to illustrate the case where it contains a sensitive value which should not be displayed on the help screen. Closes https://github.com/clap-rs/clap/issues/2101
This commit is contained in:
parent
6a56a82629
commit
2a2cf81977
1 changed files with 7 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
//! How to use environment variable fallback an how it
|
||||
//! interacts with `default_value`.
|
||||
|
||||
use clap::Clap;
|
||||
use clap::{ArgSettings, Clap};
|
||||
|
||||
/// Example for allowing to specify options via environment variables.
|
||||
#[derive(Clap, Debug)]
|
||||
|
@ -18,6 +18,12 @@ struct Opt {
|
|||
/// Number of retries
|
||||
#[clap(long, env = "RETRIES", default_value = "5")]
|
||||
retries: u32,
|
||||
|
||||
// If an environment variable contains a sensitive value, it can be hidden
|
||||
// from the help screen with a special setting.
|
||||
/// Secret token
|
||||
#[clap(long, env = "SECRET_TOKEN", setting = ArgSettings::HideEnvValues)]
|
||||
token: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
Loading…
Reference in a new issue