2017-07-04 21:59:27 +00:00
|
|
|
//! `git.rs` serves as a demonstration of how to use subcommands,
|
|
|
|
//! as well as a demonstration of adding documentation to subcommands.
|
|
|
|
//! Documentation can be added either through doc comments or the
|
|
|
|
//! `about` attribute.
|
|
|
|
|
2018-05-21 14:54:22 +00:00
|
|
|
#[macro_use]
|
2018-07-02 18:45:17 +00:00
|
|
|
extern crate clap;
|
2017-07-04 21:59:27 +00:00
|
|
|
|
2018-07-02 18:45:17 +00:00
|
|
|
use clap::Clap;
|
2017-07-04 21:59:27 +00:00
|
|
|
|
2018-07-02 18:45:17 +00:00
|
|
|
#[derive(Clap, Debug)]
|
|
|
|
#[clap(name = "git")]
|
2017-07-04 21:59:27 +00:00
|
|
|
/// the stupid content tracker
|
|
|
|
enum Opt {
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(name = "fetch")]
|
2017-07-04 21:59:27 +00:00
|
|
|
/// fetch branches from remote repository
|
|
|
|
Fetch {
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(long = "dry-run")]
|
2017-07-04 21:59:27 +00:00
|
|
|
dry_run: bool,
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(long = "all")]
|
2017-07-04 21:59:27 +00:00
|
|
|
all: bool,
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(default_value = "origin")]
|
2018-05-21 14:54:22 +00:00
|
|
|
repository: String,
|
2017-07-04 21:59:27 +00:00
|
|
|
},
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(name = "add")]
|
2017-07-04 21:59:27 +00:00
|
|
|
/// add files to the staging area
|
|
|
|
Add {
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(short = "i")]
|
2017-07-04 21:59:27 +00:00
|
|
|
interactive: bool,
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(short = "a")]
|
2017-07-04 21:59:27 +00:00
|
|
|
all: bool,
|
2018-05-21 14:54:22 +00:00
|
|
|
files: Vec<String>,
|
|
|
|
},
|
2017-07-04 21:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2018-07-02 18:45:17 +00:00
|
|
|
let matches = Opt::parse();
|
2017-07-04 21:59:27 +00:00
|
|
|
|
|
|
|
println!("{:?}", matches);
|
|
|
|
}
|