Matthew Maurer | 32e7669 | 2020-06-02 11:15:15 -0700 | [diff] [blame^] | 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 | use structopt::StructOpt; |
| 7 | |
| 8 | #[derive(StructOpt, Debug)] |
| 9 | #[structopt(name = "git")] |
| 10 | /// the stupid content tracker |
| 11 | enum Opt { |
| 12 | /// fetch branches from remote repository |
| 13 | Fetch { |
| 14 | #[structopt(long)] |
| 15 | dry_run: bool, |
| 16 | #[structopt(long)] |
| 17 | all: bool, |
| 18 | #[structopt(default_value = "origin")] |
| 19 | repository: String, |
| 20 | }, |
| 21 | #[structopt(help = "add files to the staging area")] |
| 22 | Add { |
| 23 | #[structopt(short)] |
| 24 | interactive: bool, |
| 25 | #[structopt(short)] |
| 26 | all: bool, |
| 27 | files: Vec<String>, |
| 28 | }, |
| 29 | } |
| 30 | |
| 31 | fn main() { |
| 32 | let matches = Opt::from_args(); |
| 33 | |
| 34 | println!("{:?}", matches); |
| 35 | } |