Commit 0e9ec008a2
Unsigned
Layout: unified · split
src/commands/keys.rs +2 −2
| @@ -19,6 +19,7 @@ pub struct KeysCommand { | |||
| 19 | 19 | ||
| 20 | impl KeysCommand { | 20 | impl KeysCommand { |
| 21 | pub const DESCRIPTION: &'static str = "Import or export E2EE keys."; | 21 | pub const DESCRIPTION: &'static str = "Import or export E2EE keys."; |
| 22 | pub const COMPLETION: &'static str = "import|export %(filename)"; | ||
| 22 | 23 | ||
| 23 | pub fn create(servers: &Servers) -> Result<Command, ()> { | 24 | pub fn create(servers: &Servers) -> Result<Command, ()> { |
| 24 | let settings = CommandSettings::new("keys") | 25 | let settings = CommandSettings::new("keys") |
| @@ -29,8 +30,7 @@ impl KeysCommand { | |||
| 29 | .arguments_description( | 30 | .arguments_description( |
| 30 | "file: Path to a file that is or will contain the E2EE keys export", | 31 | "file: Path to a file that is or will contain the E2EE keys export", |
| 31 | ) | 32 | ) |
| 32 | .add_completion("import %(filename)") | 33 | .add_completion(Self::COMPLETION) |
| 33 | .add_completion("export %(filename)") | ||
| 34 | .add_completion("help import|export"); | 34 | .add_completion("help import|export"); |
| 35 | 35 | ||
| 36 | Command::new( | 36 | Command::new( |
src/commands/matrix.rs +16 −3
| @@ -11,8 +11,9 @@ use weechat::{ | |||
| 11 | }; | 11 | }; |
| 12 | 12 | ||
| 13 | use crate::{ | 13 | use crate::{ |
| 14 | commands::DevicesCommand, config::ConfigHandle, MatrixServer, Servers, | 14 | commands::{DevicesCommand, KeysCommand}, |
| 15 | PLUGIN_NAME, | 15 | config::ConfigHandle, |
| 16 | MatrixServer, Servers, PLUGIN_NAME, | ||
| 16 | }; | 17 | }; |
| 17 | 18 | ||
| 18 | pub struct MatrixCommand { | 19 | pub struct MatrixCommand { |
| @@ -31,6 +32,7 @@ impl MatrixCommand { | |||
| 31 | .add_argument("server delete|list|listfull <server-name>") | 32 | .add_argument("server delete|list|listfull <server-name>") |
| 32 | .add_argument("connect <server-name>") | 33 | .add_argument("connect <server-name>") |
| 33 | .add_argument("devices delete|list|set-name") | 34 | .add_argument("devices delete|list|set-name") |
| 35 | .add_argument("keys import|export <file> <passphrase>") | ||
| 34 | .add_argument("disconnect <server-name>") | 36 | .add_argument("disconnect <server-name>") |
| 35 | .add_argument("reconnect <server-name>") | 37 | .add_argument("reconnect <server-name>") |
| 36 | .add_argument("help <matrix-command> [<matrix-subcommand>]") | 38 | .add_argument("help <matrix-command> [<matrix-subcommand>]") |
| @@ -40,12 +42,15 @@ impl MatrixCommand { | |||
| 40 | disconnect: Disconnect from one or all Matrix servers. | 42 | disconnect: Disconnect from one or all Matrix servers. |
| 41 | reconnect: Reconnect to server(s). | 43 | reconnect: Reconnect to server(s). |
| 42 | devices: {} | 44 | devices: {} |
| 45 | keys: {} | ||
| 43 | help: Show detailed command help.\n | 46 | help: Show detailed command help.\n |
| 44 | Use /matrix [command] help to find out more.\n", | 47 | Use /matrix [command] help to find out more.\n", |
| 45 | DevicesCommand::DESCRIPTION | 48 | DevicesCommand::DESCRIPTION, |
| 49 | KeysCommand::DESCRIPTION, | ||
| 46 | )) | 50 | )) |
| 47 | .add_completion("server |add|delete|list|listfull") | 51 | .add_completion("server |add|delete|list|listfull") |
| 48 | .add_completion("devices |list|delete|set-name") | 52 | .add_completion("devices |list|delete|set-name") |
| 53 | .add_completion(&format!("keys {}", KeysCommand::COMPLETION)) | ||
| 49 | .add_completion("connect") | 54 | .add_completion("connect") |
| 50 | .add_completion("disconnect") | 55 | .add_completion("disconnect") |
| 51 | .add_completion("reconnect") | 56 | .add_completion("reconnect") |
| @@ -266,6 +271,11 @@ impl CommandCallback for MatrixCommand { | |||
| 266 | .about(DevicesCommand::DESCRIPTION) | 271 | .about(DevicesCommand::DESCRIPTION) |
| 267 | .subcommands(DevicesCommand::subcommands()), | 272 | .subcommands(DevicesCommand::subcommands()), |
| 268 | ) | 273 | ) |
| 274 | .subcommand( | ||
| 275 | SubCommand::with_name("keys") | ||
| 276 | .about(KeysCommand::DESCRIPTION) | ||
| 277 | .subcommands(KeysCommand::subcommands()), | ||
| 278 | ) | ||
| 269 | .subcommand( | 279 | .subcommand( |
| 270 | SubCommand::with_name("connect") | 280 | SubCommand::with_name("connect") |
| 271 | .about("Connect to Matrix servers.") | 281 | .about("Connect to Matrix servers.") |
| @@ -308,6 +318,9 @@ impl CommandCallback for MatrixCommand { | |||
| 308 | ("devices", Some(subargs)) => { | 318 | ("devices", Some(subargs)) => { |
| 309 | DevicesCommand::run(buffer, &self.servers, subargs) | 319 | DevicesCommand::run(buffer, &self.servers, subargs) |
| 310 | } | 320 | } |
| 321 | ("keys", Some(subargs)) => { | ||
| 322 | KeysCommand::run(buffer, &self.servers, subargs) | ||
| 323 | } | ||
| 311 | _ => unreachable!(), | 324 | _ => unreachable!(), |
| 312 | } | 325 | } |
| 313 | } | 326 | } |