aboutsummaryrefslogtreecommitdiff
path: root/examples/at_least_two.rs
blob: a4eb0028e77263d0b777864cfa988135f448dd97 (plain)
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
//! How to require presence of at least N values,
//! like `val1 val2 ... valN ... valM`.
//!
//! Running this example with --help prints this message:
//! -----------------------------------------------------
//! structopt 0.3.25
//!
//! USAGE:
//!     at_least_two <foos>...
//!
//! FLAGS:
//!     -h, --help       Prints help information
//!     -V, --version    Prints version information
//!
//! ARGS:
//!     <foos>...
//! -----------------------------------------------------

use structopt::StructOpt;

#[derive(StructOpt, Debug)]
struct Opt {
    #[structopt(required = true, min_values = 2)]
    foos: Vec<String>,
}

fn main() {
    let opt = Opt::from_args();
    println!("{:?}", opt);
}