diff options
author | Teddy Wing | 2021-03-20 13:40:37 +0100 |
---|---|---|
committer | Teddy Wing | 2021-03-20 13:40:37 +0100 |
commit | 46373d4d0f9d425a3132529b546b2d83c3796a37 (patch) | |
tree | 5362d329505c2a449e1b902d93c4fa6356119778 | |
parent | 2a7d9f54af1c6fa96c313a4644e481cfff3c0a8b (diff) | |
download | mutt-ottolangy-46373d4d0f9d425a3132529b546b2d83c3796a37.tar.bz2 |
main(): Add a version command line argument
Make it easy to find out what version of the program is installed.
-rw-r--r-- | src/main.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index e96684f..b170a17 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,7 @@ use thiserror::Error; use whatlang::{self, Lang}; use xdg; +use std::env; use std::fs::File; use std::io::{self, Read, Write}; use std::process; @@ -78,6 +79,16 @@ enum OttolangyError { fn main() { + let args: Vec<String> = env::args().collect(); + + if args.len() == 2 + && (args[1] == "-V" || args[1] == "--version") + { + println!("{}", env!("CARGO_PKG_VERSION")); + + process::exit(exitcode::OK) + } + match run() { Ok(_) => (), Err(e) => { |