File: rename_all_env.rs

package info (click to toggle)
rust-structopt 0.3.26-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 796 kB
  • sloc: makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,026 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
mod utils;

use structopt::StructOpt;
use utils::*;

#[test]
fn it_works() {
    #[derive(Debug, PartialEq, StructOpt)]
    #[structopt(rename_all_env = "kebab")]
    struct BehaviorModel {
        #[structopt(env)]
        be_nice: String,
    }

    let help = get_help::<BehaviorModel>();
    assert!(help.contains("[env: be-nice=]"));
}

#[test]
fn default_is_screaming() {
    #[derive(Debug, PartialEq, StructOpt)]
    struct BehaviorModel {
        #[structopt(env)]
        be_nice: String,
    }

    let help = get_help::<BehaviorModel>();
    assert!(help.contains("[env: BE_NICE=]"));
}

#[test]
fn overridable() {
    #[derive(Debug, PartialEq, StructOpt)]
    #[structopt(rename_all_env = "kebab")]
    struct BehaviorModel {
        #[structopt(env)]
        be_nice: String,

        #[structopt(rename_all_env = "pascal", env)]
        be_agressive: String,
    }

    let help = get_help::<BehaviorModel>();
    assert!(help.contains("[env: be-nice=]"));
    assert!(help.contains("[env: BeAgressive=]"));
}