Commit 66392177eb

66392177ebbce7e878a940644bf42db90179a136

parent: 55027ce8a7

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-01-12 16:52 UTC

commands: Implement the connect subcommand.

Layout: unified · split

src/commands.rs +20 −5
@@ -247,12 +247,27 @@ Use /matrix [command] help to find out more.\n",
247247
248248 match matches.subcommand() {
249249 ("connect", Some(subargs)) => {
250 weechat.print("Connecting");
250 let server_names = subargs.values_of("name")
251 .expect("Server names not set but were required");
252
251253 let mut servers = servers.borrow_mut();
252 for server in servers.values_mut() {
253 match server.connect() {
254 Ok(_) => (),
255 Err(e) => weechat.print(&format!("{:?}", e)),
254
255 for server_name in server_names {
256 let server = servers.get_mut(server_name);
257 if let Some(s) = server {
258 match s.connect() {
259 Ok(_) => (),
260 Err(e) => weechat.print(&format!("{:?}", e)),
261 }
262 } else {
263 weechat.print(&format!(
264 "{}{}: Server \"{}{}{}\" not found.",
265 weechat.prefix("error"),
266 PLUGIN_NAME,
267 weechat.color("chat_server"),
268 server_name,
269 weechat.color("reset")
270 ));
256271 }
257272 }
258273 }