aboutsummaryrefslogtreecommitdiffstats
path: root/mumctl/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mumctl/src/main.rs')
-rw-r--r--mumctl/src/main.rs30
1 files changed, 21 insertions, 9 deletions
diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs
index 6e97296..7f74077 100644
--- a/mumctl/src/main.rs
+++ b/mumctl/src/main.rs
@@ -172,11 +172,11 @@ fn main() {
};
if let Some(config) = config {
- config.write_default_cfg();
+ config.write_default_cfg().unwrap();
}
}
-fn match_server_connect(matches : &clap::ArgMatches<>) {
+fn match_server_connect(matches : &clap::ArgMatches<'_>) {
let host = matches.value_of("host").unwrap();
let username = matches.value_of("username").unwrap();
let port = match matches.value_of("port").map(|e| e.parse()) {
@@ -185,16 +185,28 @@ fn match_server_connect(matches : &clap::ArgMatches<>) {
Some(Ok(v)) => Some(v),
};
if let Some(port) = port {
- err_print!(send_command(Command::ServerConnect {
+ match send_command(Command::ServerConnect {
host: host.to_string(),
port,
username: username.to_string(),
accept_invalid_cert: true, //TODO
- }));
+ }) {
+ Ok(e) => {
+ if let Some(CommandResponse::ServerConnect { welcome_message }) = e {
+ println!("Connected to {}", host);
+ if let Some(message) = welcome_message {
+ println!("Welcome: {}", message);
+ }
+ }
+ }
+ Err(e) => {
+ println!("{} {}", "error:".red(), e);
+ }
+ };
}
}
-fn match_server_config(matches: &clap::ArgMatches<>, config: &mut mumlib::config::Config) {
+fn match_server_config(matches: &clap::ArgMatches<'_>, config: &mut mumlib::config::Config) {
let server_name = matches.value_of("server_name").unwrap();
if let Some(servers) = &mut config.servers {
let server = servers
@@ -252,7 +264,7 @@ fn match_server_config(matches: &clap::ArgMatches<>, config: &mut mumlib::config
}
}
-fn match_server_rename(matches: &clap::ArgMatches<>, config: &mut mumlib::config::Config) {
+fn match_server_rename(matches: &clap::ArgMatches<'_>, config: &mut mumlib::config::Config) {
if let Some(servers) = &mut config.servers {
let prev_name = matches.value_of("prev_name").unwrap();
let next_name = matches.value_of("next_name").unwrap();
@@ -266,7 +278,7 @@ fn match_server_rename(matches: &clap::ArgMatches<>, config: &mut mumlib::config
}
}
-fn match_server_remove(matches: &clap::ArgMatches<>, config: &mut mumlib::config::Config) {
+fn match_server_remove(matches: &clap::ArgMatches<'_>, config: &mut mumlib::config::Config) {
let name = matches.value_of("name").unwrap();
if let Some(servers) = &mut config.servers {
match servers.iter().position(|server| server.name == name) {
@@ -282,7 +294,7 @@ fn match_server_remove(matches: &clap::ArgMatches<>, config: &mut mumlib::config
}
}
-fn match_server_add(matches: &clap::ArgMatches<>, config: &mut mumlib::config::Config) {
+fn match_server_add(matches: &clap::ArgMatches<'_>, config: &mut mumlib::config::Config) {
let name = matches.value_of("name").unwrap().to_string();
let host = matches.value_of("host").unwrap().to_string();
// optional arguments map None to None
@@ -364,7 +376,7 @@ fn print_channel(channel: &Channel, depth: usize) {
);
for user in &channel.users {
println!(
- "{}-{}",
+ "{}- {}",
iter::repeat(INDENTATION)
.take(depth + 1)
.collect::<String>(),