aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 4d810b0..efe4477 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,6 +13,7 @@ fn main() {
let args: Vec<String> = env::args().collect();
let mut opts = Options::new();
+ opts.optflag("h", "help", "print this help menu");
let matches = match opts.parse(&args[1..]) {
Ok(m) => m,
@@ -22,6 +23,11 @@ fn main() {
},
};
+ if matches.opt_present("h") {
+ print_usage(&opts);
+ process::exit(exitcode::USAGE);
+ }
+
let repo = match Repository::open(".") {
Ok(r) => r,
Err(e) => {
@@ -70,6 +76,12 @@ fn main() {
};
}
+/// Print command line usage.
+fn print_usage(opts: &Options) {
+ let brief = "usage: git todo [<commit>]";
+ print!("{}", opts.usage(&brief));
+}
+
/// Print to standard error with a program-specific prefix.
fn eprintln<D: std::fmt::Display>(error: &D) {
eprintln!("error: {}", error);