aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bin/einhyrningsinsctl.rs8
-rw-r--r--src/main.rs14
2 files changed, 20 insertions, 2 deletions
diff --git a/src/bin/einhyrningsinsctl.rs b/src/bin/einhyrningsinsctl.rs
index c057b9e..0e55073 100644
--- a/src/bin/einhyrningsinsctl.rs
+++ b/src/bin/einhyrningsinsctl.rs
@@ -108,17 +108,23 @@ fn main() {
let mut opts = Options::new();
opts.optflag("h", "help", "print this help menu");
+ opts.optflag("", "version", "print the version");
let matches = match opts.parse(&args[1..]) {
Ok(m) => { m }
Err(f) => { println!("{}", f.to_string()); print_usage(opts); exit(-1); }
};
- if matches.opt_present("h") {
+ if matches.opt_present("help") {
print_usage(opts);
return;
}
+ if matches.opt_present("version") {
+ println!("einhyrningsinsctl {}", env!("CARGO_PKG_VERSION"));
+ return;
+ }
+
// Bind to Control Socket
let ctrl_path = Path::new("/tmp/einhorn.sock");
// XXX: handle this more gracefully (per-process)
diff --git a/src/main.rs b/src/main.rs
index 725cdbd..8699433 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -371,6 +371,7 @@ fn main() {
let mut opts = Options::new();
opts.parsing_style(getopts::ParsingStyle::StopAtFirstFree);
opts.optflag("h", "help", "print this help menu");
+ opts.optflag("", "version", "print the version");
opts.optflag("v", "verbose", "more debugging messages");
opts.optflag("4", "ipv4-only", "only accept IPv4 connections");
opts.optflag("6", "ipv6-only", "only accept IPv6 connections");
@@ -383,11 +384,16 @@ fn main() {
Err(f) => { println!("{}", f.to_string()); print_usage(opts); exit(-1); }
};
- if matches.opt_present("h") {
+ if matches.opt_present("help") {
print_usage(opts);
return;
}
+ if matches.opt_present("version") {
+ println!("einhyrningsins {}", env!("CARGO_PKG_VERSION"));
+ return;
+ }
+
if matches.opt_present("4") && matches.opt_present("6") {
println!("Can't be both IPv4-only and IPv6-only");
exit(-1);
@@ -562,6 +568,12 @@ fn ctrl_socket_handle(stream: UnixStream, ctrl_req_tx: Sender<CtrlRequest>) {
writer.flush().unwrap();
continue;
},
+ Some("version") => {
+ let ver = format!("\"einhyrningsinsctl {}\"\n", env!("CARGO_PKG_VERSION"));
+ writer.write_all(ver.as_bytes()).unwrap();
+ writer.flush().unwrap();
+ continue;
+ },
Some(_) | None => {
writer.write_all("\"Missing or unhandled 'command'\"\n".as_bytes()).unwrap();
writer.flush().unwrap();