From d5e89508c97eda58e76766c4dbaa605905727268 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 26 Oct 2018 03:46:58 +0200 Subject: config: Add `--version` flag Should print the version of the program. Doesn't actually do any printing in Rust, because the Rust library's version number is different from the DomeKey program version. We just indicate to the Objective-C code that it should print the version number. --- src/config.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/config.rs b/src/config.rs index b4cab10..6b9d673 100644 --- a/src/config.rs +++ b/src/config.rs @@ -16,6 +16,7 @@ type Milliseconds = u16; pub struct Args { pub reload: bool, pub daemon: bool, + pub version: bool, pub license: *mut c_char, } @@ -24,6 +25,7 @@ impl Default for Args { Args { reload: false, daemon: false, + version: false, license: ptr::null_mut(), } } @@ -63,6 +65,7 @@ pub fn parse_args<'a>(args: &[String], config: &'a mut Config) -> &'a mut Config "register the software using a license plist file", "FILE" ); + opts.optflag("v", "version", "print the program version"); opts.optflag("h", "help", "print this help menu"); let matches = match opts.parse(&args[1..]) { @@ -84,6 +87,8 @@ pub fn parse_args<'a>(args: &[String], config: &'a mut Config) -> &'a mut Config Ok(str) => config.args.license = str.into_raw(), Err(e) => dkeprintln!("{}", e), } + } else if matches.opt_present("v") { + config.args.version = true; } else { print_usage(opts); } -- cgit v1.2.3