aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2019-11-02 20:48:40 +0100
committerTeddy Wing2019-11-02 20:57:38 +0100
commiteb2f9c78a4698ccc2d09e5021fbf7155e49f561d (patch)
treed62e55fc2ac69cb08b066e66bff599f3e4739d62
parentf0e87f4e91bc60a7ab86dcd9819368082c102b82 (diff)
downloadpdf-urls-eb2f9c78a4698ccc2d09e5021fbf7155e49f561d.tar.bz2
Add a `--version` flag
-rw-r--r--doc/pdf-urls.16
-rw-r--r--doc/pdf-urls.1.txt5
-rw-r--r--src/main.rs13
3 files changed, 23 insertions, 1 deletions
diff --git a/doc/pdf-urls.1 b/doc/pdf-urls.1
index e58ad01..3e90edc 100644
--- a/doc/pdf-urls.1
+++ b/doc/pdf-urls.1
@@ -35,6 +35,12 @@ pdf-urls \- Extract URLs from a PDF file
.SH "DESCRIPTION"
.sp
Extract all URLs from a PDF file and print them, one per line, to standard output\&.
+.SH "OPTIONS"
+.PP
+\-v, \-\-version
+.RS 4
+Print the program version\&.
+.RE
.SH "EXAMPLES"
.sp
The following extracts URLs from the document \fIfile\&.pdf\fR and passes them to \fBurlview\fR to be opened in a browser:
diff --git a/doc/pdf-urls.1.txt b/doc/pdf-urls.1.txt
index 18ef69e..ddc2048 100644
--- a/doc/pdf-urls.1.txt
+++ b/doc/pdf-urls.1.txt
@@ -14,6 +14,11 @@ DESCRIPTION
Extract all URLs from a PDF file and print them, one per line, to
standard output.
+OPTIONS
+-------
+-v, --version::
+ Print the program version.
+
EXAMPLES
--------
The following extracts URLs from the document 'file.pdf' and passes them
diff --git a/src/main.rs b/src/main.rs
index 9c1fd97..8f246b3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,8 +22,13 @@ use std::process;
use pdf_urls::get_urls_from_pdf;
+const VERSION: &'static str = "0.0.1";
+
fn print_usage() {
- println!("usage: pdf-urls FILE");
+ println!(r#"usage: pdf-urls [<options>] FILE
+
+Options:
+ -v, --version print the program version"#);
}
fn main() {
@@ -35,6 +40,12 @@ fn main() {
process::exit(exitcode::USAGE);
}
+ if args[1] == "-v" || args[1] == "--version" {
+ println!("{}", VERSION);
+
+ process::exit(exitcode::OK);
+ }
+
match get_urls_from_pdf(&args[1]) {
Ok(urls) => {
for url in urls {