2019-12-06 09:48:32 +00:00
|
|
|
mod utils;
|
|
|
|
|
2021-07-13 17:50:55 +00:00
|
|
|
use clap::Parser;
|
2019-12-06 09:48:32 +00:00
|
|
|
use utils::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn it_works() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Debug, PartialEq, Parser)]
|
2019-12-06 09:48:32 +00:00
|
|
|
#[clap(rename_all_env = "kebab")]
|
|
|
|
struct BehaviorModel {
|
|
|
|
#[clap(env)]
|
|
|
|
be_nice: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
let help = get_help::<BehaviorModel>();
|
|
|
|
assert!(help.contains("[env: be-nice=]"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn default_is_screaming() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Debug, PartialEq, Parser)]
|
2019-12-06 09:48:32 +00:00
|
|
|
struct BehaviorModel {
|
|
|
|
#[clap(env)]
|
|
|
|
be_nice: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
let help = get_help::<BehaviorModel>();
|
|
|
|
assert!(help.contains("[env: BE_NICE=]"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn overridable() {
|
2021-07-13 17:50:55 +00:00
|
|
|
#[derive(Debug, PartialEq, Parser)]
|
2019-12-06 09:48:32 +00:00
|
|
|
#[clap(rename_all_env = "kebab")]
|
|
|
|
struct BehaviorModel {
|
|
|
|
#[clap(env)]
|
|
|
|
be_nice: String,
|
|
|
|
|
|
|
|
#[clap(rename_all_env = "pascal", env)]
|
2021-10-19 01:38:22 +00:00
|
|
|
be_aggressive: String,
|
2019-12-06 09:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let help = get_help::<BehaviorModel>();
|
|
|
|
assert!(help.contains("[env: be-nice=]"));
|
2021-10-19 01:38:22 +00:00
|
|
|
assert!(help.contains("[env: BeAggressive=]"));
|
2019-12-06 09:48:32 +00:00
|
|
|
}
|