From 22579ced3d1d847a14683fe3b47fa2076df01751 Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Thu, 5 Nov 2020 00:44:04 +0100 Subject: add mute feature --- mumctl/src/main.rs | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'mumctl/src') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 2805545..478ecaa 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -110,7 +110,31 @@ fn main() { ) .arg(Arg::with_name("user").required(true)) .setting(AppSettings::SubcommandsNegateReqs), - ); + ) + .subcommand(SubCommand::with_name("mute") + .subcommand(SubCommand::with_name("true") + .alias("1")) + .subcommand(SubCommand::with_name("false") + .alias("0")) + .subcommand(SubCommand::with_name("toggle")) + .setting(AppSettings::SubcommandRequiredElseHelp)) + .subcommand(SubCommand::with_name("deafen") + .subcommand(SubCommand::with_name("true") + .alias("1")) + .subcommand(SubCommand::with_name("false") + .alias("0")) + .subcommand(SubCommand::with_name("toggle")) + .setting(AppSettings::SubcommandRequiredElseHelp)) + .subcommand(SubCommand::with_name("user") + .arg(Arg::with_name("user").required(true)) + .subcommand(SubCommand::with_name("mute") + .subcommand(SubCommand::with_name("true") + .alias("1")) + .subcommand(SubCommand::with_name("false") + .alias("0")) + .subcommand(SubCommand::with_name("toggle")) + .setting(AppSettings::SubcommandRequiredElseHelp)) + .setting(AppSettings::SubcommandRequiredElseHelp)); let matches = app.clone().get_matches(); @@ -226,6 +250,46 @@ fn main() { //TODO implement me //needs work on mumd to implement } + } else if let Some(matches) = matches.subcommand_matches("mute") { + let command = Command::MuteSelf( + if let Some(_matches) = matches.subcommand_matches("true") { + Some(true) + } else if let Some(_matches) = matches.subcommand_matches("false") { + Some(false) + } else if let Some(_matches) = matches.subcommand_matches("toggle") { + None + } else { + unreachable!() + }); + err_print!(send_command(command)); + } else if let Some(matches) = matches.subcommand_matches("deafen") { + let command = Command::DeafenSelf( + if let Some(_matches) = matches.subcommand_matches("true") { + Some(true) + } else if let Some(_matches) = matches.subcommand_matches("false") { + Some(false) + } else if let Some(_matches) = matches.subcommand_matches("toggle") { + None + } else { + unreachable!() + }); + err_print!(send_command(command)); + } else if let Some(matches) = matches.subcommand_matches("user") { + let name = matches.value_of("user").unwrap(); + if let Some(matches) = matches.subcommand_matches("mute") { + let toggle = if let Some(_matches) = matches.subcommand_matches("true") { + Some(true) + } else if let Some(_matches) = matches.subcommand_matches("false") { + Some(false) + } else if let Some(_matches) = matches.subcommand_matches("toggle") { + None + } else { + unreachable!() + }; + err_print!(send_command(Command::MuteOther(name.to_string(), toggle))); + } else { + unreachable!(); + } }; if !config::cfg_exists() { -- cgit v1.2.1 From 7a4e0c79be76444a8f3a8d4019175a8eb84d333e Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Thu, 5 Nov 2020 00:44:48 +0100 Subject: cargo fmt --- mumctl/src/main.rs | 59 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'mumctl/src') diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 478ecaa..22e08ec 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -111,30 +111,32 @@ fn main() { .arg(Arg::with_name("user").required(true)) .setting(AppSettings::SubcommandsNegateReqs), ) - .subcommand(SubCommand::with_name("mute") - .subcommand(SubCommand::with_name("true") - .alias("1")) - .subcommand(SubCommand::with_name("false") - .alias("0")) - .subcommand(SubCommand::with_name("toggle")) - .setting(AppSettings::SubcommandRequiredElseHelp)) - .subcommand(SubCommand::with_name("deafen") - .subcommand(SubCommand::with_name("true") - .alias("1")) - .subcommand(SubCommand::with_name("false") - .alias("0")) - .subcommand(SubCommand::with_name("toggle")) - .setting(AppSettings::SubcommandRequiredElseHelp)) - .subcommand(SubCommand::with_name("user") - .arg(Arg::with_name("user").required(true)) - .subcommand(SubCommand::with_name("mute") - .subcommand(SubCommand::with_name("true") - .alias("1")) - .subcommand(SubCommand::with_name("false") - .alias("0")) + .subcommand( + SubCommand::with_name("mute") + .subcommand(SubCommand::with_name("true").alias("1")) + .subcommand(SubCommand::with_name("false").alias("0")) .subcommand(SubCommand::with_name("toggle")) - .setting(AppSettings::SubcommandRequiredElseHelp)) - .setting(AppSettings::SubcommandRequiredElseHelp)); + .setting(AppSettings::SubcommandRequiredElseHelp), + ) + .subcommand( + SubCommand::with_name("deafen") + .subcommand(SubCommand::with_name("true").alias("1")) + .subcommand(SubCommand::with_name("false").alias("0")) + .subcommand(SubCommand::with_name("toggle")) + .setting(AppSettings::SubcommandRequiredElseHelp), + ) + .subcommand( + SubCommand::with_name("user") + .arg(Arg::with_name("user").required(true)) + .subcommand( + SubCommand::with_name("mute") + .subcommand(SubCommand::with_name("true").alias("1")) + .subcommand(SubCommand::with_name("false").alias("0")) + .subcommand(SubCommand::with_name("toggle")) + .setting(AppSettings::SubcommandRequiredElseHelp), + ) + .setting(AppSettings::SubcommandRequiredElseHelp), + ); let matches = app.clone().get_matches(); @@ -155,7 +157,8 @@ fn main() { if config.servers.len() == 0 { println!("{} No servers in config", "warning:".yellow()); } - for (server, response) in config.servers + for (server, response) in config + .servers .iter() .map(|e| { let response = send_command(Command::ServerStatus { @@ -251,8 +254,8 @@ fn main() { //needs work on mumd to implement } } else if let Some(matches) = matches.subcommand_matches("mute") { - let command = Command::MuteSelf( - if let Some(_matches) = matches.subcommand_matches("true") { + let command = + Command::MuteSelf(if let Some(_matches) = matches.subcommand_matches("true") { Some(true) } else if let Some(_matches) = matches.subcommand_matches("false") { Some(false) @@ -263,8 +266,8 @@ fn main() { }); err_print!(send_command(command)); } else if let Some(matches) = matches.subcommand_matches("deafen") { - let command = Command::DeafenSelf( - if let Some(_matches) = matches.subcommand_matches("true") { + let command = + Command::DeafenSelf(if let Some(_matches) = matches.subcommand_matches("true") { Some(true) } else if let Some(_matches) = matches.subcommand_matches("false") { Some(false) -- cgit v1.2.1