blob: 6e4137bda48eb825199b0fd36e1beba6b09bc299 [file] [log] [blame]
Matthew Maurer32e76692020-06-02 11:15:15 -07001//! `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.
David LeGare12ae7f82022-03-02 16:20:50 +00005//!
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//! -----------------------------------------------------
Matthew Maurer32e76692020-06-02 11:15:15 -070023
24use structopt::StructOpt;
25
26#[derive(StructOpt, Debug)]
27#[structopt(name = "git")]
28/// the stupid content tracker
29enum 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
49fn main() {
50 let matches = Opt::from_args();
51
52 println!("{:?}", matches);
53}