aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mumctl/Cargo.toml1
-rw-r--r--mumctl/src/main.rs59
2 files changed, 46 insertions, 14 deletions
diff --git a/mumctl/Cargo.toml b/mumctl/Cargo.toml
index 1f2f727..c955afa 100644
--- a/mumctl/Cargo.toml
+++ b/mumctl/Cargo.toml
@@ -12,6 +12,7 @@ edition = "2018"
mumlib = { path = "../mumlib" }
clap = { version = "2.33", features = ["yaml"] }
+colored = "2.0"
log = "0.4"
ipc-channel = "0.14"
diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs
index d6c046d..01c5743 100644
--- a/mumctl/src/main.rs
+++ b/mumctl/src/main.rs
@@ -4,6 +4,15 @@ use log::*;
use mumlib::command::{Command, CommandResponse};
use mumlib::setup_logger;
use std::{fs, io};
+use colored::Colorize;
+
+macro_rules! err_print {
+ ($func:expr) => {
+ if let Err(e) = $func {
+ println!("{} {}", "error:".red(), e);
+ }
+ };
+}
fn main() {
setup_logger();
@@ -41,36 +50,58 @@ fn main() {
.long("fish")));
let matches = app.clone().get_matches();
-
- debug!("Matching clap");
+
if let Some(matches) = matches.subcommand_matches("server") {
if let Some(matches) = matches.subcommand_matches("connect") {
let host = matches.value_of("host").unwrap();
let username = matches.value_of("username").unwrap();
- send_command(Command::ServerConnect {
+ err_print!(send_command(Command::ServerConnect {
host: host.to_string(),
port: 64738u16, //TODO
username: username.to_string(),
accept_invalid_cert: true, //TODO
- }).unwrap();
+ }));
+ /*if let Err(e) = send_command(Command::ServerConnect {
+ host: host.to_string(),
+ port: 64738u16, //TODO
+ username: username.to_string(),
+ accept_invalid_cert: true, //TODO
+ }) {
+ println!("{} {}", "error:".red(), e);
+ }*/
} else if let Some(_) = matches.subcommand_matches("disconnect") {
- send_command(Command::ServerDisconnect).unwrap();
+ err_print!(send_command(Command::ServerDisconnect));
}
} else if let Some(matches) = matches.subcommand_matches("channel") {
if let Some(_matches) = matches.subcommand_matches("list") {
- let res = send_command(Command::ChannelList).unwrap().unwrap();
- println!("{:#?}", res);
- /*if matches.is_present("short") {
- None //TODO
- } else {
- None //TODO
- };*/
+ match send_command(Command::ChannelList) {
+ Ok(res) => {
+ println!("{:#?}", res.unwrap());
+ /*if matches.is_present("short") {
+ None //TODO
+ } else {
+ None //TODO
+ };*/
+ }
+ Err(e) => println!("{} {}", "error:".red(), e),
+ }
} else if let Some(matches) = matches.subcommand_matches("connect") {
- send_command(Command::ChannelJoin {
+ err_print!(send_command(Command::ChannelJoin {
channel_id: matches.value_of("channel").unwrap().parse::<u32>().unwrap()
- }).unwrap();
+ }));
}
} else if let Some(_matches) = matches.subcommand_matches("status") {
+ match send_command(Command::Status) {
+ Ok(res) => {
+ println!("{:#?}", res.unwrap());
+ /*if matches.is_present("short") {
+ None //TODO
+ } else {
+ None //TODO
+ };*/
+ }
+ Err(e) => println!("{} {}", "error:".red(), e),
+ }
let res = send_command(Command::Status).unwrap().unwrap();
println!("{:#?}", res);
} else if let Some(matches) = matches.subcommand_matches("completions") {