diff options
author | Teddy Wing | 2017-05-07 13:48:27 +0200 |
---|---|---|
committer | Teddy Wing | 2017-05-07 13:48:27 +0200 |
commit | 1e4cbaa5f2285b673d5335612265e1fcd298ca82 (patch) | |
tree | b6ac6c145bf274bbe9d0bfa9a55f6be0baa4c6f5 /src/main.rs | |
parent | 09d7aa3f3dc1a2b9241bc0ec62bee029b8942dc1 (diff) | |
download | HearURL-1e4cbaa5f2285b673d5335612265e1fcd298ca82.tar.bz2 |
main.rs: Add port command line option
Provide users with an option to change the default port the program
listens on.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index c6e7054..098a8bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,6 +45,7 @@ fn main() { let mut opts = Options::new(); opts.optopt("b", "browser", "set browser", "BROWSER"); + opts.optopt("p", "port", "set port number", "PORT"); opts.optflag("h", "help", "print this help menu"); let opt_matches = match opts.parse(&args[1..]) { @@ -65,6 +66,11 @@ fn main() { }, }; + let port: u16 = match opt_matches.opt_str("p") { + Some(p) => p.parse().unwrap(), + None => 37705, + }; + open_stream().unwrap_or_else(|e| { writeln!(io::stderr(), "{}", e) .expect("Failed printing to stderr"); |