Commit 8c1ea75910
Unsigned
Layout: unified · split
src/commands.rs +30 −13
| @@ -20,24 +20,24 @@ impl Commands { | ||
| 20 | 20 | ) -> Commands { |
| 21 | 21 | let matrix_desc = CommandDescription { |
| 22 | 22 | name: "matrix", |
| 23 | description: "Matrix chat protocol command", | |
| 24 | args: "server add <server-name> <hostname>[:<port>] ||\ | |
| 23 | description: "Matrix chat protocol command.", | |
| 24 | args: "server add <server-name> <hostname>[:<port>]||\ | |
| 25 | 25 | server delete|list|listfull <server-name> ||\ |
| 26 | 26 | connect <server-name> ||\ |
| 27 | 27 | disconnect <server-name> ||\ |
| 28 | 28 | reconnect <server-name> ||\ |
| 29 | help <matrix-command>", | |
| 30 | args_description: " server: list, add, or remove Matrix servers | |
| 31 | connect: connect to Matrix servers | |
| 32 | disconnect: disconnect from one or all Matrix servers | |
| 33 | reconnect: reconnect to server(s) | |
| 34 | help: show detailed command help\n | |
| 35 | Use /matrix help [command] to find out more.\n", | |
| 29 | help <matrix-command> [<matrix-subcommand>]", | |
| 30 | args_description: " server: List, add, or remove Matrix servers. | |
| 31 | connect: Connect to Matrix servers. | |
| 32 | disconnect: Disconnect from one or all Matrix servers. | |
| 33 | reconnect: Reconnect to server(s). | |
| 34 | help: Show detailed command help.\n | |
| 35 | Use /matrix [command] help to find out more.\n", | |
| 36 | 36 | completion: "server |add|delete|list|listfull || |
| 37 | 37 | connect || |
| 38 | 38 | disconnect || |
| 39 | 39 | reconnect || |
| 40 | help", | |
| 40 | help server|connect|disconnect|reconnect" | |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | let matrix = weechat.hook_command( |
| @@ -97,8 +97,10 @@ Use /matrix help [command] to find out more.\n", | ||
| 97 | 97 | ) { |
| 98 | 98 | let weechat = unsafe { Weechat::weechat() }; |
| 99 | 99 | let server_command = SubCommand::with_name("server") |
| 100 | .about("List, add or delete Matrix servers.") | |
| 100 | 101 | .subcommand( |
| 101 | 102 | SubCommand::with_name("add") |
| 103 | .about("Add a new Matrix server.") | |
| 102 | 104 | .arg( |
| 103 | 105 | Arg::with_name("name") |
| 104 | 106 | .value_name("server-name") |
| @@ -110,17 +112,32 @@ Use /matrix help [command] to find out more.\n", | ||
| 110 | 112 | .validator(MatrixServer::parse_homeserver_url), |
| 111 | 113 | ), |
| 112 | 114 | ) |
| 113 | .subcommand(SubCommand::with_name("delete")); | |
| 115 | .subcommand( | |
| 116 | SubCommand::with_name("delete") | |
| 117 | .about("Delete an existing Matrix server.") | |
| 118 | .arg( | |
| 119 | Arg::with_name("name") | |
| 120 | .value_name("server-name") | |
| 121 | .required(true), | |
| 122 | ), | |
| 123 | ); | |
| 114 | 124 | |
| 115 | 125 | let argparse = Argparse::new("matrix") |
| 126 | .about("Matrix chat protocol command.") | |
| 116 | 127 | .global_setting(ArgParseSettings::ColorNever) |
| 117 | 128 | .global_setting(ArgParseSettings::DisableHelpFlags) |
| 118 | 129 | .global_setting(ArgParseSettings::DisableVersion) |
| 119 | 130 | .global_setting(ArgParseSettings::VersionlessSubcommands) |
| 120 | 131 | .setting(ArgParseSettings::SubcommandRequiredElseHelp) |
| 121 | 132 | .subcommand(server_command) |
| 122 | .subcommand(SubCommand::with_name("connect")) | |
| 123 | .subcommand(SubCommand::with_name("disconnect")); | |
| 133 | .subcommand( | |
| 134 | SubCommand::with_name("connect") | |
| 135 | .about("Connect to Matrix servers."), | |
| 136 | ) | |
| 137 | .subcommand( | |
| 138 | SubCommand::with_name("disconnect") | |
| 139 | .about("Disconnect from one or all Matrix servers"), | |
| 140 | ); | |
| 124 | 141 | |
| 125 | 142 | let matches = match argparse.get_matches_from_safe(args) { |
| 126 | 143 | Ok(m) => m, |