aboutsummaryrefslogtreecommitdiffstats
path: root/mumctl/src
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2020-10-18 01:41:16 +0200
committerEskil Queseth <eskilq@kth.se>2020-10-18 01:41:16 +0200
commit1d782cdf5fc7c1c427b477970256a8cb11be3562 (patch)
tree7638a01e19d1b85463bf125918575415738a3631 /mumctl/src
parentccc5f76133460d055a5d90ae9cd0a7bc2a83551d (diff)
downloadmum-1d782cdf5fc7c1c427b477970256a8cb11be3562.tar.gz
add option to choose port
Diffstat (limited to 'mumctl/src')
-rw-r--r--mumctl/src/main.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs
index 2473195..4443f46 100644
--- a/mumctl/src/main.rs
+++ b/mumctl/src/main.rs
@@ -28,7 +28,8 @@ fn main() {
SubCommand::with_name("connect")
.setting(AppSettings::ArgRequiredElseHelp)
.arg(Arg::with_name("host").required(true).index(1))
- .arg(Arg::with_name("username").required(true).index(2)),
+ .arg(Arg::with_name("username").required(true).index(2))
+ .arg(Arg::with_name("port").short("p").long("port").takes_value(true)),
)
.subcommand(SubCommand::with_name("disconnect")),
)
@@ -63,12 +64,19 @@ fn main() {
if let Some(matches) = matches.subcommand_matches("connect") {
let host = matches.value_of("host").unwrap();
let username = matches.value_of("username").unwrap();
- err_print!(send_command(Command::ServerConnect {
- host: host.to_string(),
- port: 64738u16, //TODO
- username: username.to_string(),
- accept_invalid_cert: true, //TODO
- }));
+ let port = match matches.value_of("port").map(|e| e.parse()) {
+ None => Some(64738),
+ Some(Err(_)) => None,
+ Some(Ok(v)) => Some(v),
+ };
+ if let Some(port) = port {
+ err_print!(send_command(Command::ServerConnect {
+ host: host.to_string(),
+ port,
+ username: username.to_string(),
+ accept_invalid_cert: true, //TODO
+ }));
+ }
} else if let Some(_) = matches.subcommand_matches("disconnect") {
err_print!(send_command(Command::ServerDisconnect));
}