| @@ -42,6 +42,7 @@ impl MatrixCommand { |
| 42 | .add_argument("media download <mxc-uri> [file]") |
42 | .add_argument("media download <mxc-uri> [file]") |
| 43 | .add_argument("disconnect <server-name>") |
43 | .add_argument("disconnect <server-name>") |
| 44 | .add_argument("reconnect <server-name>") |
44 | .add_argument("reconnect <server-name>") |
| |
45 | .add_argument("sso-complete <server-name> <login-token>") |
| 45 | .add_argument("read") |
46 | .add_argument("read") |
| 46 | .add_argument("help <matrix-command> [<matrix-subcommand>]") |
47 | .add_argument("help <matrix-command> [<matrix-subcommand>]") |
| 47 | .arguments_description(format!( |
48 | .arguments_description(format!( |
| @@ -50,6 +51,7 @@ impl MatrixCommand { |
| 50 | disconnect: Disconnect from one or all Matrix servers. |
51 | disconnect: Disconnect from one or all Matrix servers. |
| 51 | reconnect: Reconnect to server(s). |
52 | reconnect: Reconnect to server(s). |
| 52 | join: Join a Matrix room by ID or alias. |
53 | join: Join a Matrix room by ID or alias. |
| |
54 | sso-complete: Finish SSO login with a copied loginToken. |
| 53 | read: Mark the current room as read. |
55 | read: Mark the current room as read. |
| 54 | devices: {} |
56 | devices: {} |
| 55 | keys: {} |
57 | keys: {} |
| @@ -73,8 +75,9 @@ Use /matrix [command] help to find out more.\n", |
| 73 | .add_completion("connect %(matrix_servers)") |
75 | .add_completion("connect %(matrix_servers)") |
| 74 | .add_completion("disconnect %(matrix_servers)") |
76 | .add_completion("disconnect %(matrix_servers)") |
| 75 | .add_completion("reconnect %(matrix_servers)") |
77 | .add_completion("reconnect %(matrix_servers)") |
| |
78 | .add_completion("sso-complete %(matrix_servers)") |
| 76 | .add_completion( |
79 | .add_completion( |
| 77 | "help server|connect|disconnect|reconnect|join|read|keys|devices|media", |
80 | "help server|connect|disconnect|reconnect|join|sso-complete|read|keys|devices|media", |
| 78 | ); |
81 | ); |
| 79 | |
82 | |
| 80 | Command::new( |
83 | Command::new( |
| @@ -231,6 +234,22 @@ Use /matrix [command] help to find out more.\n", |
| 231 | } |
234 | } |
| 232 | } |
235 | } |
| 233 | |
236 | |
| |
237 | fn sso_complete_command(&self, args: &ArgMatches) { |
| |
238 | let server_name = args |
| |
239 | .value_of("name") |
| |
240 | .expect("Server name not set but was required"); |
| |
241 | let login_token = args |
| |
242 | .value_of("login-token") |
| |
243 | .expect("Login token not set but was required") |
| |
244 | .to_owned(); |
| |
245 | |
| |
246 | if let Some(s) = self.servers.get(server_name) { |
| |
247 | s.complete_sso_login(login_token); |
| |
248 | } else { |
| |
249 | self.server_not_found(server_name) |
| |
250 | } |
| |
251 | } |
| |
252 | |
| 234 | fn join_command(&self, buffer: &Buffer, args: &ArgMatches) { |
253 | fn join_command(&self, buffer: &Buffer, args: &ArgMatches) { |
| 235 | let room_id_or_alias = args |
254 | let room_id_or_alias = args |
| 236 | .value_of("room") |
255 | .value_of("room") |
| @@ -251,6 +270,9 @@ Use /matrix [command] help to find out more.\n", |
| 251 | match args.subcommand() { |
270 | match args.subcommand() { |
| 252 | ("connect", Some(subargs)) => self.connect_command(subargs), |
271 | ("connect", Some(subargs)) => self.connect_command(subargs), |
| 253 | ("disconnect", Some(subargs)) => self.disconnect_command(subargs), |
272 | ("disconnect", Some(subargs)) => self.disconnect_command(subargs), |
| |
273 | ("sso-complete", Some(subargs)) => { |
| |
274 | self.sso_complete_command(subargs) |
| |
275 | } |
| 254 | ("join", Some(subargs)) => self.join_command(buffer, subargs), |
276 | ("join", Some(subargs)) => self.join_command(buffer, subargs), |
| 255 | ("server", Some(subargs)) => self.server_command(subargs), |
277 | ("server", Some(subargs)) => self.server_command(subargs), |
| 256 | ("devices", Some(subargs)) => { |
278 | ("devices", Some(subargs)) => { |
| @@ -368,6 +390,20 @@ impl CommandCallback for MatrixCommand { |
| 368 | .required(true), |
390 | .required(true), |
| 369 | ), |
391 | ), |
| 370 | ) |
392 | ) |
| |
393 | .subcommand( |
| |
394 | SubCommand::with_name("sso-complete") |
| |
395 | .about("Finish SSO login with a copied loginToken") |
| |
396 | .arg( |
| |
397 | Arg::with_name("name") |
| |
398 | .value_name("server-name") |
| |
399 | .required(true), |
| |
400 | ) |
| |
401 | .arg( |
| |
402 | Arg::with_name("login-token") |
| |
403 | .value_name("login-token") |
| |
404 | .required(true), |
| |
405 | ), |
| |
406 | ) |
| 371 | .subcommand( |
407 | .subcommand( |
| 372 | SubCommand::with_name("join") |
408 | SubCommand::with_name("join") |
| 373 | .about("Join a Matrix room by ID or alias") |
409 | .about("Join a Matrix room by ID or alias") |