Commit 8c1ea75910

8c1ea7591048b55e0553600d2207c6940745b66f

parent: 78d7909586

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-01-11 21:18 UTC

commands: More descriptions for the commands.

Layout: unified · split

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