Commit c5dc1a8ebc
Unsigned
Layout: unified · split
src/commands.rs +18 −19
| @@ -7,7 +7,7 @@ use crate::config::Config; | |||
| 7 | use crate::PLUGIN_NAME; | 7 | use crate::PLUGIN_NAME; |
| 8 | use crate::{MatrixServer, Servers}; | 8 | use crate::{MatrixServer, Servers}; |
| 9 | use weechat::buffer::Buffer; | 9 | use weechat::buffer::Buffer; |
| 10 | use weechat::hooks::{CommandSettings, Command, CommandCallback}; | 10 | use weechat::hooks::{Command, CommandCallback, CommandSettings}; |
| 11 | use weechat::{ArgsWeechat, Weechat}; | 11 | use weechat::{ArgsWeechat, Weechat}; |
| 12 | 12 | ||
| 13 | pub struct Commands { | 13 | pub struct Commands { |
| @@ -121,12 +121,8 @@ impl MatrixCommand { | |||
| 121 | 121 | ||
| 122 | fn server_command(&self, args: &ArgMatches) { | 122 | fn server_command(&self, args: &ArgMatches) { |
| 123 | match args.subcommand() { | 123 | match args.subcommand() { |
| 124 | ("add", Some(subargs)) => { | 124 | ("add", Some(subargs)) => self.add_server(subargs), |
| 125 | self.add_server(subargs) | 125 | ("delete", Some(subargs)) => self.delete_server(subargs), |
| 126 | } | ||
| 127 | ("delete", Some(subargs)) => { | ||
| 128 | self.delete_server(subargs) | ||
| 129 | } | ||
| 130 | ("list", _) => self.list_servers(), | 126 | ("list", _) => self.list_servers(), |
| 131 | _ => self.list_servers(), | 127 | _ => self.list_servers(), |
| 132 | } | 128 | } |
| @@ -181,7 +177,12 @@ impl MatrixCommand { | |||
| 181 | } | 177 | } |
| 182 | 178 | ||
| 183 | impl CommandCallback for MatrixCommand { | 179 | impl 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 | ) { | ||
| 185 | let server_command = SubCommand::with_name("server") | 186 | let server_command = SubCommand::with_name("server") |
| 186 | .about("List, add or delete Matrix servers.") | 187 | .about("List, add or delete Matrix servers.") |
| 187 | .subcommand( | 188 | .subcommand( |
| @@ -256,15 +257,9 @@ impl CommandCallback for MatrixCommand { | |||
| 256 | }; | 257 | }; |
| 257 | 258 | ||
| 258 | match matches.subcommand() { | 259 | match matches.subcommand() { |
| 259 | ("connect", Some(subargs)) => { | 260 | ("connect", Some(subargs)) => self.connect_command(subargs), |
| 260 | self.connect_command(subargs) | 261 | ("disconnect", Some(subargs)) => self.disconnect_command(subargs), |
| 261 | } | 262 | ("server", Some(subargs)) => self.server_command(subargs), |
| 262 | ("disconnect", Some(subargs)) => { | ||
| 263 | self.disconnect_command(subargs) | ||
| 264 | } | ||
| 265 | ("server", Some(subargs)) => { | ||
| 266 | self.server_command(subargs) | ||
| 267 | } | ||
| 268 | _ => unreachable!(), | 263 | _ => unreachable!(), |
| 269 | } | 264 | } |
| 270 | } | 265 | } |
| @@ -290,7 +285,8 @@ impl Commands { | |||
| 290 | disconnect: Disconnect from one or all Matrix servers. | 285 | disconnect: Disconnect from one or all Matrix servers. |
| 291 | reconnect: Reconnect to server(s). | 286 | reconnect: Reconnect to server(s). |
| 292 | help: Show detailed command help.\n | 287 | help: Show detailed command help.\n |
| 293 | Use /matrix [command] help to find out more.\n") | 288 | Use /matrix [command] help to find out more.\n", |
| 289 | ) | ||
| 294 | .add_completion("server |add|delete|list|listfull") | 290 | .add_completion("server |add|delete|list|listfull") |
| 295 | .add_completion("connect") | 291 | .add_completion("connect") |
| 296 | .add_completion("disconnect") | 292 | .add_completion("disconnect") |
| @@ -299,7 +295,10 @@ Use /matrix [command] help to find out more.\n") | |||
| 299 | 295 | ||
| 300 | let matrix = weechat.hook_command( | 296 | let matrix = weechat.hook_command( |
| 301 | matrix_settings, | 297 | matrix_settings, |
| 302 | MatrixCommand { servers: servers.clone(), config: config.clone() } | 298 | MatrixCommand { |
| 299 | servers: servers.clone(), | ||
| 300 | config: config.clone(), | ||
| 301 | }, | ||
| 303 | ); | 302 | ); |
| 304 | 303 | ||
| 305 | Commands { _matrix: matrix } | 304 | Commands { _matrix: matrix } |
src/lib.rs +1 −3
| @@ -89,9 +89,7 @@ impl WeechatPlugin for Matrix { | |||
| 89 | let config = Config::new(weechat, &servers); | 89 | let config = Config::new(weechat, &servers); |
| 90 | let commands = Commands::hook_all(weechat, &servers, &config); | 90 | let commands = Commands::hook_all(weechat, &servers, &config); |
| 91 | 91 | ||
| 92 | tracing_subscriber::fmt() | 92 | tracing_subscriber::fmt().with_writer(debug::Debug).init(); |
| 93 | .with_writer(debug::Debug) | ||
| 94 | .init(); | ||
| 95 | 93 | ||
| 96 | let matrix = Matrix { | 94 | let matrix = Matrix { |
| 97 | servers: servers.clone(), | 95 | servers: servers.clone(), |