2022-06-13 22:00:39 +00:00
|
|
|
#![cfg(feature = "env")]
|
|
|
|
|
|
|
|
use crate::utils;
|
|
|
|
|
|
|
|
use clap::Parser;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn it_works() {
|
|
|
|
#[derive(Debug, PartialEq, Parser)]
|
|
|
|
#[clap(rename_all_env = "kebab")]
|
|
|
|
struct BehaviorModel {
|
2022-06-13 22:04:50 +00:00
|
|
|
#[clap(env)]
|
2022-06-13 22:00:39 +00:00
|
|
|
be_nice: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
let help = utils::get_help::<BehaviorModel>();
|
|
|
|
assert!(help.contains("[env: be-nice=]"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn default_is_screaming() {
|
|
|
|
#[derive(Debug, PartialEq, Parser)]
|
|
|
|
struct BehaviorModel {
|
2022-06-13 22:04:50 +00:00
|
|
|
#[clap(env)]
|
2022-06-13 22:00:39 +00:00
|
|
|
be_nice: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
let help = utils::get_help::<BehaviorModel>();
|
|
|
|
assert!(help.contains("[env: BE_NICE=]"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn overridable() {
|
|
|
|
#[derive(Debug, PartialEq, Parser)]
|
|
|
|
#[clap(rename_all_env = "kebab")]
|
|
|
|
struct BehaviorModel {
|
2022-06-13 22:04:50 +00:00
|
|
|
#[clap(env)]
|
2022-06-13 22:00:39 +00:00
|
|
|
be_nice: String,
|
|
|
|
|
2022-06-13 22:04:50 +00:00
|
|
|
#[clap(rename_all_env = "pascal", env)]
|
2022-06-13 22:00:39 +00:00
|
|
|
be_aggressive: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
let help = utils::get_help::<BehaviorModel>();
|
|
|
|
assert!(help.contains("[env: be-nice=]"));
|
|
|
|
assert!(help.contains("[env: BeAggressive=]"));
|
|
|
|
}
|