From 1fe6a2d8d37a2a66c926b725b6cd461baac26f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sat, 21 Nov 2020 12:34:24 +0100 Subject: make connect and disconnect root-commands While writing some about-texts for the CLI, I noticed that the server-command did two things. 1. Connect and disconnect 2. Handle saved servers --- mumctl/src/main.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 22e08ec..5ce521a 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -25,21 +25,21 @@ fn main() { let mut app = App::new("mumctl") .setting(AppSettings::ArgRequiredElseHelp) + .subcommand( + SubCommand::with_name("connect") + .arg(Arg::with_name("host").required(true)) + .arg(Arg::with_name("username")) + .arg( + Arg::with_name("port") + .long("port") + .short("p") + .takes_value(true), + ), + ) + .subcommand(SubCommand::with_name("disconnect")) .subcommand( SubCommand::with_name("server") .setting(AppSettings::ArgRequiredElseHelp) - .subcommand( - SubCommand::with_name("connect") - .arg(Arg::with_name("host").required(true)) - .arg(Arg::with_name("username")) - .arg( - Arg::with_name("port") - .long("port") - .short("p") - .takes_value(true), - ), - ) - .subcommand(SubCommand::with_name("disconnect")) .subcommand( SubCommand::with_name("config") .arg(Arg::with_name("server_name")) @@ -140,12 +140,12 @@ fn main() { let matches = app.clone().get_matches(); - if let Some(matches) = matches.subcommand_matches("server") { - if let Some(matches) = matches.subcommand_matches("connect") { - match_server_connect(matches, &config); - } else if let Some(_) = matches.subcommand_matches("disconnect") { - err_print!(send_command(Command::ServerDisconnect)); - } else if let Some(matches) = matches.subcommand_matches("config") { + if let Some(matches) = matches.subcommand_matches("connect") { + match_server_connect(matches, &config); + } else if let Some(_) = matches.subcommand_matches("disconnect") { + err_print!(send_command(Command::ServerDisconnect)); + } else if let Some(matches) = matches.subcommand_matches("server") { + if let Some(matches) = matches.subcommand_matches("config") { match_server_config(matches, &mut config); } else if let Some(matches) = matches.subcommand_matches("rename") { match_server_rename(matches, &mut config); -- cgit v1.2.1