File: regressions.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 (45 lines) | stat: -rw-r--r-- 897 bytes parent folder | download | duplicates (2)
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
use structopt::StructOpt;

mod utils;
use utils::*;

#[test]
fn invisible_group_issue_439() {
    macro_rules! m {
        ($bool:ty) => {
            #[derive(Debug, StructOpt)]
            struct Opts {
                #[structopt(long = "x")]
                x: $bool,
            }
        };
    }

    m!(bool);

    let help = get_long_help::<Opts>();

    assert!(help.contains("--x"));
    assert!(!help.contains("--x <x>"));
    Opts::from_iter_safe(&["test", "--x"]).unwrap();
}

#[test]
fn issue_447() {
    macro_rules! Command {
        ( $name:ident, [
        #[$meta:meta] $var:ident($inner:ty)
      ] ) => {
            #[derive(Debug, PartialEq, structopt::StructOpt)]
            enum $name {
                #[$meta]
                $var($inner),
            }
        };
    }

    Command! {GitCmd, [
      #[structopt(external_subcommand)]
      Ext(Vec<String>)
    ]}
}