(I'm not sure if this should be on structopt or clap-rs),
This is a feature request so env may be used without any value (lik short/long), and be automatically (but differently) renamed.
Quick example:
from this:
#[derive(Clone, Debug, Deserialize, Serialize, StructOpt)]
#[serde(rename_all = "kebab-case")]
#[structopt(rename_all = "kebab-case")]
pub struct Config {
#[structopt(long, env = "BIND_ADDR", default_value = "127.0.0.1:8080")]
/// Address which the server will bind to.
pub bind_addr: SocketAddr,
}
into this:
#[derive(Clone, Debug, Deserialize, Serialize, StructOpt)]
#[serde(rename_all = "kebab-case")]
#[structopt(rename_all = "kebab-case")]
#[structopt(rename_all_env = "SCREAMING_SNAKE_CASE")]
pub struct Config {
#[structopt(long, env, default_value = "127.0.0.1:8080")]
/// Address which the server will bind to.
pub bind_addr: SocketAddr,
}
That would be a structopt feature, not sens in clap.
Even the default rename_all_env value can be by default to SCREAMING_SNAKE_CASE as it would only be used by env without argument and that would be a new feature.
Thanks for the suggestion, great idea.
I'm voting for implementing this as #[structopt(rename_all_env)], should I do that? cc @TeXitoi
OK.
Most helpful comment
That would be a structopt feature, not sens in clap.
Even the default rename_all_env value can be by default to SCREAMING_SNAKE_CASE as it would only be used by env without argument and that would be a new feature.
Thanks for the suggestion, great idea.