diff options
author | Teddy Wing | 2019-11-02 21:06:35 +0100 |
---|---|---|
committer | Teddy Wing | 2019-11-02 21:06:35 +0100 |
commit | 1d5bbbd55d2307cd0c50e54e08f1ee632066eefb (patch) | |
tree | 45963462af870fcf1c37a2ee7cbac1b859fdef0c | |
parent | eb2f9c78a4698ccc2d09e5021fbf7155e49f561d (diff) | |
download | pdf-urls-1d5bbbd55d2307cd0c50e54e08f1ee632066eefb.tar.bz2 |
Add a `--help` flag
-rw-r--r-- | doc/pdf-urls.1 | 5 | ||||
-rw-r--r-- | doc/pdf-urls.1.txt | 3 | ||||
-rw-r--r-- | src/main.rs | 7 |
3 files changed, 15 insertions, 0 deletions
diff --git a/doc/pdf-urls.1 b/doc/pdf-urls.1 index 3e90edc..7554d45 100644 --- a/doc/pdf-urls.1 +++ b/doc/pdf-urls.1 @@ -37,6 +37,11 @@ pdf-urls \- Extract URLs from a PDF file Extract all URLs from a PDF file and print them, one per line, to standard output\&. .SH "OPTIONS" .PP +\-h, \-\-help +.RS 4 +Print usage help\&. +.RE +.PP \-v, \-\-version .RS 4 Print the program version\&. diff --git a/doc/pdf-urls.1.txt b/doc/pdf-urls.1.txt index ddc2048..294a98f 100644 --- a/doc/pdf-urls.1.txt +++ b/doc/pdf-urls.1.txt @@ -16,6 +16,9 @@ standard output. OPTIONS ------- +-h, --help:: + Print usage help. + -v, --version:: Print the program version. diff --git a/src/main.rs b/src/main.rs index 8f246b3..12d5725 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ fn print_usage() { println!(r#"usage: pdf-urls [<options>] FILE Options: + -h, --help print this help menu -v, --version print the program version"#); } @@ -40,6 +41,12 @@ fn main() { process::exit(exitcode::USAGE); } + if args[1] == "-h" || args[1] == "--help" { + print_usage(); + + process::exit(exitcode::OK); + } + if args[1] == "-v" || args[1] == "--version" { println!("{}", VERSION); |