@@ -7,7 +7,9 @@ local S = core.get_translator("__builtin")
77core .registered_chatcommands = {}
88
99-- Interpret the parameters of a command, separating options and arguments.
10- -- Input: parameters of a command
10+ -- Input: command, param
11+ -- command: name of command
12+ -- param: parameters of command
1113-- Returns: opts, args
1214-- opts is a string of option letters, or false on error
1315-- args is an array with the non-option arguments in order, or an error message
@@ -19,14 +21,14 @@ core.registered_chatcommands = {}
1921-- "cdg", {"a", "b", "e", "f"}
2022-- Negative numbers are taken as arguments. Long options (--option) are
2123-- currently rejected as reserved.
22- local function getopts (param )
24+ local function getopts (command , param )
2325 local opts = " "
2426 local args = {}
2527 for match in param :gmatch (" %S+" ) do
2628 if match :byte (1 ) == 45 then -- 45 = '-'
2729 local second = match :byte (2 )
2830 if second == 45 then
29- return false , S (" Flags beginning with -- are reserved " )
31+ return false , S (" Invalid parameters (see /help @1). " , command )
3032 elseif second and (second < 48 or second > 57 ) then -- 48 = '0', 57 = '9'
3133 opts = opts .. match :sub (2 )
3234 else
@@ -80,7 +82,7 @@ local function format_help_line(cmd, def)
8082end
8183
8284local function do_help_cmd (name , param )
83- local opts , args = getopts (param )
85+ local opts , args = getopts (" help " , param )
8486 if not opts then
8587 return false , args
8688 end
0 commit comments