aboutsummaryrefslogtreecommitdiffstats
path: root/mumctl/src
diff options
context:
space:
mode:
authorEskil <eskilq@kth.se>2020-10-18 02:14:51 +0200
committerEskil <eskilq@kth.se>2020-10-18 02:14:51 +0200
commitd688a68a0e15d295ac375059616640312614ad4f (patch)
treef343d065b8598b7daa08892d438c80f5ad79e9e1 /mumctl/src
parentcf25e7862e2b44c84e2c1bb0bfc3106c44d5aade (diff)
parent1d782cdf5fc7c1c427b477970256a8cb11be3562 (diff)
downloadmum-d688a68a0e15d295ac375059616640312614ad4f.tar.gz
Merge branch 'port-configuration' into 'main'
Add option to choose port Closes #33 See merge request gustav/mum!13
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 5b19309..f4b8139 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));
}