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",
51 Commands { _matrix: matrix } 51 Commands { _matrix: matrix }
52 } 52 }
53 53
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
54 fn server_command( 73 fn server_command(
55 args: &ArgMatches, 74 args: &ArgMatches,
56 servers: &Servers, 75 servers: &Servers,
@@ -140,7 +159,9 @@ Use /matrix [command] help to find out more.\n",
140 weechat.color("reset") 159 weechat.color("reset")
141 )); 160 ));
142 } 161 }
143 _ => (), 162
163 ("list", _) => Commands::list_servers(servers),
164 _ => Commands::list_servers(servers),
144 } 165 }
145 } 166 }
146 167