Commit 937494a040

937494a040322923c4c05a4cc718deac1ebafbfa

parent: a95880aa86

Unsigned

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

commands: Implement the list subcommand for the server command.

Layout: unified · split

src/commands.rs +22 −1
@@ -51,6 +51,25 @@ Use /matrix [command] help to find out more.\n",
5151 Commands { _matrix: matrix }
5252 }
5353
54 fn list_servers(servers: &Servers) {
55 let weechat = unsafe { Weechat::weechat() };
56
57 if servers.borrow().is_empty() {
58 return;
59 }
60
61 weechat.print("\nAll Matrix servers:");
62
63 // TODO print out some stats if the server is connected.
64 for server in servers.borrow().keys() {
65 weechat.print(&format!(
66 " {}{}",
67 weechat.color("chat_server"),
68 server
69 ));
70 }
71 }
72
5473 fn server_command(
5574 args: &ArgMatches,
5675 servers: &Servers,
@@ -140,7 +159,9 @@ Use /matrix [command] help to find out more.\n",
140159 weechat.color("reset")
141160 ));
142161 }
143 _ => (),
162
163 ("list", _) => Commands::list_servers(servers),
164 _ => Commands::list_servers(servers),
144165 }
145166 }
146167