-
I want to use clap to collect the options to my program. However, I don't want users to have the option of providing their account tokens on the command line. I want to require they be provided in the environment use clap::Parser;
#[derive(Debug, Clone, Parser)]
struct Cli {
#[clap(short, long, help="Account ID", env = "ACCOUNT_ID")]
account_id: u32,
// How do I still show this in the --help,
// but indicate that it must be set from the environment?
#[clap(help="Account Auth Token", env = "ACCOUNT_AUTH_TOKEN")]
account_auth_token: String,
} I'm aware that I could just do this manually with hide/skip and document it in the command about. And then just read it from std::env::vars, but I was hoping clap had a facility to do this itself since it seems like a rather desirable thing people would want to do when dealing with secrets. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Clap does not have general application configuration support, even for env variables. Thats a topic for #2763. |
Beta Was this translation helpful? Give feedback.
Clap does not have general application configuration support, even for env variables. Thats a topic for #2763.