aboutsummaryrefslogtreecommitdiff
path: root/structopt/examples/at_least_two.rs
diff options
context:
space:
mode:
Diffstat (limited to 'structopt/examples/at_least_two.rs')
-rw-r--r--structopt/examples/at_least_two.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/structopt/examples/at_least_two.rs b/structopt/examples/at_least_two.rs
new file mode 100644
index 0000000..683db50
--- /dev/null
+++ b/structopt/examples/at_least_two.rs
@@ -0,0 +1,15 @@
+//! How to require presence of at least N values,
+//! like `val1 val2 ... valN ... valM`.
+
+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);
+}