aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-04-12 23:11:32 +0200
committerTeddy Wing2021-04-12 23:11:32 +0200
commit6ad5626a5d6ac98a9da445dc706a338d1475eb54 (patch)
treefb28f0c29dae7a8aa034b1fc2d86bbaa7e38c7ad
parent0c8a97cd2f67481722a9c1eda6cea4d93a2955cf (diff)
downloadformurapid-6ad5626a5d6ac98a9da445dc706a338d1475eb54.tar.bz2
Add `--help` and `--version` flags
-rw-r--r--src/main.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 96c0f98..e688968 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -52,8 +52,21 @@ fn run() -> anyhow::Result<()> {
opts.optflag("", "fill", "fill in the form using a markup file");
opts.optflag("", "generate", "generate helper files to fill in the form");
+ opts.optflag("h", "help", "print this help menu");
+ opts.optflag("V", "version", "show the program version");
+
let opt_matches = opts.parse(&args[1..])?;
+ if opt_matches.opt_present("h") {
+ print_usage(&opts);
+ process::exit(exitcode::USAGE);
+ }
+
+ if opt_matches.opt_present("V") {
+ println!("{}", env!("CARGO_PKG_VERSION"));
+ process::exit(exitcode::OK);
+ }
+
if opt_matches.free.is_empty() {
print_usage(&opts);