summaryrefslogtreecommitdiff
path: root/src/bin/main.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2017-06-17 10:17:31 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2017-06-17 10:17:31 -0400
commit55a773304461a2c261823c6d4bab38b66e95dc07 (patch)
treed28cb7e3d6e425530476f5c919135bd3999b028d /src/bin/main.rs
parent6221d330e12c2b5738301eb0a63e584fa4cc9db4 (diff)
Add port number flag.
Diffstat (limited to 'src/bin/main.rs')
-rw-r--r--src/bin/main.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index b54c4c0..94bdd71 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -4,9 +4,22 @@
extern crate log;
extern crate systemhttp;
extern crate env_logger;
+#[macro_use]
+extern crate clap;
fn main() {
+ let matches = clap_app!(
+ systemhttpd =>
+ (version: "0.1")
+ (author: "Kjetil Ørbekk")
+ (about: "A systemd web frontend")
+ (@arg PORT: -p --port +takes_value "Port to serve on"))
+ .get_matches();
+
+ let port = matches.value_of("PORT").unwrap_or("8080")
+ .parse::<u16>().expect("port number");
+
env_logger::init().unwrap();
- let _server = systemhttp::server::serve(8080).unwrap();
- println!("Serving on {}", 8080);
+ let _server = systemhttp::server::serve(port).unwrap();
+ println!("Serving on {}", port);
}