Commit c5dc1a8ebc

c5dc1a8ebcfac4c2ec9b71a90f77933f80d9470c

parent: 1476282927

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-04-29 16:24 UTC

commands: Format the file.

Layout: unified · split

src/commands.rs +18 −19
@@ -7,7 +7,7 @@ use crate::config::Config;
77use crate::PLUGIN_NAME;
88use crate::{MatrixServer, Servers};
99use weechat::buffer::Buffer;
10use weechat::hooks::{CommandSettings, Command, CommandCallback};
10use weechat::hooks::{Command, CommandCallback, CommandSettings};
1111use weechat::{ArgsWeechat, Weechat};
1212
1313pub struct Commands {
@@ -121,12 +121,8 @@ impl MatrixCommand {
121121
122122 fn server_command(&self, args: &ArgMatches) {
123123 match args.subcommand() {
124 ("add", Some(subargs)) => {
125 self.add_server(subargs)
126 }
127 ("delete", Some(subargs)) => {
128 self.delete_server(subargs)
129 }
124 ("add", Some(subargs)) => self.add_server(subargs),
125 ("delete", Some(subargs)) => self.delete_server(subargs),
130126 ("list", _) => self.list_servers(),
131127 _ => self.list_servers(),
132128 }
@@ -181,7 +177,12 @@ impl MatrixCommand {
181177}
182178
183179impl CommandCallback for MatrixCommand {
184 fn callback(&mut self, _weechat: &Weechat, _buffer: &Buffer, arguments: ArgsWeechat) {
180 fn callback(
181 &mut self,
182 _weechat: &Weechat,
183 _buffer: &Buffer,
184 arguments: ArgsWeechat,
185 ) {
185186 let server_command = SubCommand::with_name("server")
186187 .about("List, add or delete Matrix servers.")
187188 .subcommand(
@@ -256,15 +257,9 @@ impl CommandCallback for MatrixCommand {
256257 };
257258
258259 match matches.subcommand() {
259 ("connect", Some(subargs)) => {
260 self.connect_command(subargs)
261 }
262 ("disconnect", Some(subargs)) => {
263 self.disconnect_command(subargs)
264 }
265 ("server", Some(subargs)) => {
266 self.server_command(subargs)
267 }
260 ("connect", Some(subargs)) => self.connect_command(subargs),
261 ("disconnect", Some(subargs)) => self.disconnect_command(subargs),
262 ("server", Some(subargs)) => self.server_command(subargs),
268263 _ => unreachable!(),
269264 }
270265 }
@@ -290,7 +285,8 @@ impl Commands {
290285 disconnect: Disconnect from one or all Matrix servers.
291286 reconnect: Reconnect to server(s).
292287 help: Show detailed command help.\n
293Use /matrix [command] help to find out more.\n")
288Use /matrix [command] help to find out more.\n",
289 )
294290 .add_completion("server |add|delete|list|listfull")
295291 .add_completion("connect")
296292 .add_completion("disconnect")
@@ -299,7 +295,10 @@ Use /matrix [command] help to find out more.\n")
299295
300296 let matrix = weechat.hook_command(
301297 matrix_settings,
302 MatrixCommand { servers: servers.clone(), config: config.clone() }
298 MatrixCommand {
299 servers: servers.clone(),
300 config: config.clone(),
301 },
303302 );
304303
305304 Commands { _matrix: matrix }
src/lib.rs +1 −3
@@ -89,9 +89,7 @@ impl WeechatPlugin for Matrix {
8989 let config = Config::new(weechat, &servers);
9090 let commands = Commands::hook_all(weechat, &servers, &config);
9191
92 tracing_subscriber::fmt()
93 .with_writer(debug::Debug)
94 .init();
92 tracing_subscriber::fmt().with_writer(debug::Debug).init();
9593
9694 let matrix = Matrix {
9795 servers: servers.clone(),