From cd70c68a01b171ca6098550c9c034c01e826fd16 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 7 Aug 2016 14:31:34 +0200 Subject: [PATCH] Add support for --help and -h --- bin/src/main.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bin/src/main.rs b/bin/src/main.rs index fb6dba6a..03cedd72 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -125,10 +125,23 @@ fn main() { .takes_value(false) .required(false) .multiple(false) - .help("Get the versions of the imag commands")); + .help("Get the versions of the imag commands")) + .arg(Arg::with_name("help") + .long("help") + .short("h") + .takes_value(false) + .required(false) + .multiple(false) + .help("Show help")); + let matches = app.get_matches(); + if matches.is_present("help") { + help(get_commands()); + exit(0); + } + if matches.is_present("version") { println!("imag {}", &version!()[..]); exit(0);