1 //! How to add `no-thing` flag which is `true` by default and 2 //! `false` if passed. 3 //! 4 //! Running this example with --help prints this message: 5 //! ----------------------------------------------------- 6 //! structopt 0.3.25 7 //! 8 //! USAGE: 9 //! negative_flag [FLAGS] 10 //! 11 //! FLAGS: 12 //! -h, --help Prints help information 13 //! -V, --version Prints version information 14 //! --no-verbose 15 //! ----------------------------------------------------- 16 17 use structopt::StructOpt; 18 19 #[derive(Debug, StructOpt)] 20 struct Opt { 21 #[structopt(long = "no-verbose", parse(from_flag = std::ops::Not::not))] 22 verbose: bool, 23 } 24 main()25fn main() { 26 let cmd = Opt::from_args(); 27 println!("{:#?}", cmd); 28 } 29