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 //! Running this example with --help prints this message:
10 //! -----------------------------------------------------
11 //! structopt 0.3.25
12 //! An example of how to generate bash completions with structopt
13 //!
14 //! USAGE:
15 //! gen_completions [FLAGS]
16 //!
17 //! FLAGS:
18 //! -d, --debug Activate debug mode
19 //! -h, --help Prints help information
20 //! -V, --version Prints version information
21 //! -----------------------------------------------------
22
23 use structopt::clap::Shell;
24 use structopt::StructOpt;
25
26 #[derive(StructOpt, Debug)]
27 /// An example of how to generate bash completions with structopt.
28 struct Opt {
29 #[structopt(short, long)]
30 /// Activate debug mode
31 debug: bool,
32 }
33
main()34 fn main() {
35 // generate `bash` completions in "target" directory
36 Opt::clap().gen_completions("structopt", Shell::Bash, "target");
37
38 let opt = Opt::from_args();
39 println!("{:?}", opt);
40 }
41