]> git.proxmox.com Git - rustc.git/blobdiff - vendor/structopt/examples/negative_flag.rs
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / vendor / structopt / examples / negative_flag.rs
diff --git a/vendor/structopt/examples/negative_flag.rs b/vendor/structopt/examples/negative_flag.rs
new file mode 100644 (file)
index 0000000..b178bf5
--- /dev/null
@@ -0,0 +1,15 @@
+//! How to add `no-thing` flag which is `true` by default and
+//! `false` if passed.
+
+use structopt::StructOpt;
+
+#[derive(Debug, StructOpt)]
+struct Opt {
+    #[structopt(long = "no-verbose", parse(from_flag = std::ops::Not::not))]
+    verbose: bool,
+}
+
+fn main() {
+    let cmd = Opt::from_args();
+    println!("{:#?}", cmd);
+}