From 42aa40faf14db2805cc67abceef8271150450b78 Mon Sep 17 00:00:00 2001 From: Guillaume Pinot Date: Wed, 20 Nov 2019 15:03:07 +0100 Subject: [PATCH] Add an example of a negative flag (i.e. --no-verbose) Question from https://github.com/TeXitoi/structopt/issues/280 --- examples/negative_flag.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 examples/negative_flag.rs diff --git a/examples/negative_flag.rs b/examples/negative_flag.rs new file mode 100644 index 00000000..62b2932c --- /dev/null +++ b/examples/negative_flag.rs @@ -0,0 +1,12 @@ +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); +}