Matthew Maurer | 32e7669 | 2020-06-02 11:15:15 -0700 | [diff] [blame] | 1 | // Copyright 2019-present structopt developers |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 4 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 5 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 6 | // option. This file may not be copied, modified, or distributed |
| 7 | // except according to those terms. |
| 8 | |
| 9 | use structopt::clap::Shell; |
| 10 | use structopt::StructOpt; |
| 11 | |
| 12 | #[derive(StructOpt, Debug)] |
| 13 | /// An example of how to generate bash completions with structopt. |
| 14 | struct Opt { |
| 15 | #[structopt(short, long)] |
| 16 | /// Activate debug mode |
| 17 | debug: bool, |
| 18 | } |
| 19 | |
| 20 | fn main() { |
| 21 | // generate `bash` completions in "target" directory |
| 22 | Opt::clap().gen_completions(env!("CARGO_PKG_NAME"), Shell::Bash, "target"); |
| 23 | |
| 24 | let opt = Opt::from_args(); |
| 25 | println!("{:?}", opt); |
| 26 | } |