1 //! `git.rs` serves as a demonstration of how to use subcommands,
2 //! as well as a demonstration of adding documentation to subcommands.
3 //! Documentation can be added either through doc comments or
4 //! `help`/`about` attributes.
5 //!
6 //! Running this example with --help prints this message:
7 //! -----------------------------------------------------
8 //! git 0.3.25
9 //! the stupid content tracker
10 //!
11 //! USAGE:
12 //! git <SUBCOMMAND>
13 //!
14 //! FLAGS:
15 //! -h, --help Prints help information
16 //! -V, --version Prints version information
17 //!
18 //! SUBCOMMANDS:
19 //! add
20 //! fetch fetch branches from remote repository
21 //! help Prints this message or the help of the given subcommand(s)
22 //! -----------------------------------------------------
23
24 use structopt::StructOpt;
25
26 #[derive(StructOpt, Debug)]
27 #[structopt(name = "git")]
28 /// the stupid content tracker
29 enum Opt {
30 /// fetch branches from remote repository
31 Fetch {
32 #[structopt(long)]
33 dry_run: bool,
34 #[structopt(long)]
35 all: bool,
36 #[structopt(default_value = "origin")]
37 repository: String,
38 },
39 #[structopt(help = "add files to the staging area")]
40 Add {
41 #[structopt(short)]
42 interactive: bool,
43 #[structopt(short)]
44 all: bool,
45 files: Vec<String>,
46 },
47 }
48
main()49 fn main() {
50 let matches = Opt::from_args();
51
52 println!("{:?}", matches);
53 }
54