Skip to content

Commit 2ab09bb

Browse files
Ezhhnerzhul
authored andcommittedJun 15, 2017
Improve chatcommand params consistency (#5985)
* Fix and improve params consistency * Move parenthesis requirement to descriptions
1 parent f55816f commit 2ab09bb

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed
 

Diff for: ‎builtin/common/chatcommands.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ end
9797

9898
if INIT == "client" then
9999
core.register_chatcommand("help", {
100-
params = gettext("[all/<cmd>]"),
100+
params = gettext("[all | <cmd>]"),
101101
description = gettext("Get help for commands"),
102102
func = function(param)
103103
return do_help_cmd(nil, param)
104104
end,
105105
})
106106
else
107107
core.register_chatcommand("help", {
108-
params = "[all/privs/<cmd>]",
108+
params = "[all | privs | <cmd>]",
109109
description = "Get help for commands or list privileges",
110110
func = do_help_cmd,
111111
})

Diff for: ‎builtin/game/chatcommands.lua

+23-21
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ core.register_chatcommand("admin", {
9292
})
9393

9494
core.register_chatcommand("privs", {
95-
params = "<name>",
95+
params = "[<name>]",
9696
description = "Print privileges of player",
9797
func = function(caller, param)
9898
param = param:trim()
@@ -145,7 +145,7 @@ local function handle_grant_command(caller, grantname, grantprivstr)
145145
end
146146

147147
core.register_chatcommand("grant", {
148-
params = "<name> <privilege>|all",
148+
params = "<name> (<privilege> | all)",
149149
description = "Give privilege to player",
150150
func = function(name, param)
151151
local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)")
@@ -157,7 +157,7 @@ core.register_chatcommand("grant", {
157157
})
158158

159159
core.register_chatcommand("grantme", {
160-
params = "<privilege>|all",
160+
params = "<privilege> | all",
161161
description = "Grant privileges to yourself",
162162
func = function(name, param)
163163
if param == "" then
@@ -168,7 +168,7 @@ core.register_chatcommand("grantme", {
168168
})
169169

170170
core.register_chatcommand("revoke", {
171-
params = "<name> <privilege>|all",
171+
params = "<name> (<privilege> | all)",
172172
description = "Remove privilege from player",
173173
privs = {},
174174
func = function(name, param)
@@ -305,7 +305,7 @@ core.register_chatcommand("remove_player", {
305305
})
306306

307307
core.register_chatcommand("teleport", {
308-
params = "<X>,<Y>,<Z> | <to_name> | <name> <X>,<Y>,<Z> | <name> <to_name>",
308+
params = "<X>,<Y>,<Z> | <to_name> | (<name> <X>,<Y>,<Z>) | (<name> <to_name>)",
309309
description = "Teleport to player or position",
310310
privs = {teleport=true},
311311
func = function(name, param)
@@ -413,7 +413,7 @@ core.register_chatcommand("teleport", {
413413
})
414414

415415
core.register_chatcommand("set", {
416-
params = "[-n] <name> <value> | <name>",
416+
params = "([-n] <name> <value>) | <name>",
417417
description = "Set or read server configuration setting",
418418
privs = {server=true},
419419
func = function(name, param)
@@ -468,9 +468,9 @@ local function emergeblocks_progress_update(ctx)
468468
end
469469

470470
core.register_chatcommand("emergeblocks", {
471-
params = "(here [radius]) | (<pos1> <pos2>)",
471+
params = "(here [<radius>]) | (<pos1> <pos2>)",
472472
description = "Load (or, if nonexistent, generate) map blocks "
473-
.. "contained in area pos1 to pos2",
473+
.. "contained in area pos1 to pos2 (<pos1> and <pos2> must be in parentheses)",
474474
privs = {server=true},
475475
func = function(name, param)
476476
local p1, p2 = parse_range_str(name, param)
@@ -494,8 +494,9 @@ core.register_chatcommand("emergeblocks", {
494494
})
495495

496496
core.register_chatcommand("deleteblocks", {
497-
params = "(here [radius]) | (<pos1> <pos2>)",
498-
description = "Delete map blocks contained in area pos1 to pos2",
497+
params = "(here [<radius>]) | (<pos1> <pos2>)",
498+
description = "Delete map blocks contained in area pos1 to pos2 "
499+
.. "(<pos1> and <pos2> must be in parentheses)",
499500
privs = {server=true},
500501
func = function(name, param)
501502
local p1, p2 = parse_range_str(name, param)
@@ -513,8 +514,9 @@ core.register_chatcommand("deleteblocks", {
513514
})
514515

515516
core.register_chatcommand("fixlight", {
516-
params = "(here [radius]) | (<pos1> <pos2>)",
517-
description = "Resets lighting in the area between pos1 and pos2",
517+
params = "(here [<radius>]) | (<pos1> <pos2>)",
518+
description = "Resets lighting in the area between pos1 and pos2 "
519+
.. "(<pos1> and <pos2> must be in parentheses)",
518520
privs = {server = true},
519521
func = function(name, param)
520522
local p1, p2 = parse_range_str(name, param)
@@ -661,7 +663,7 @@ core.register_on_punchnode(function(pos, node, puncher)
661663
end)
662664

663665
core.register_chatcommand("rollback_check", {
664-
params = "[<range>] [<seconds>] [limit]",
666+
params = "[<range>] [<seconds>] [<limit>]",
665667
description = "Check who last touched a node or a node near it"
666668
.. " within the time specified by <seconds>. Default: range = 0,"
667669
.. " seconds = 86400 = 24h, limit = 5",
@@ -714,7 +716,7 @@ core.register_chatcommand("rollback_check", {
714716
})
715717

716718
core.register_chatcommand("rollback", {
717-
params = "<player name> [<seconds>] | :<actor> [<seconds>]",
719+
params = "(<name> [<seconds>]) | (:<actor> [<seconds>])",
718720
description = "Revert actions of a player. Default for <seconds> is 60",
719721
privs = {rollback=true},
720722
func = function(name, param)
@@ -806,8 +808,8 @@ core.register_chatcommand("days", {
806808
})
807809

808810
core.register_chatcommand("shutdown", {
809-
description = "Shutdown server",
810-
params = "[delay_in_seconds (non-negative number, or -1 to cancel)] [reconnect] [message]",
811+
params = "[<delay_in_seconds> | -1] [reconnect] [<message>]",
812+
description = "Shutdown server (-1 cancels a delayed shutdown)",
811813
privs = {server=true},
812814
func = function(name, param)
813815
local delay, reconnect, message = param:match("([^ ][-]?[0-9]+)([^ ]+)(.*)")
@@ -845,7 +847,7 @@ core.register_chatcommand("ban", {
845847
})
846848

847849
core.register_chatcommand("unban", {
848-
params = "<name/ip>",
850+
params = "<name> | <IP_address>",
849851
description = "Remove IP ban",
850852
privs = {ban=true},
851853
func = function(name, param)
@@ -858,7 +860,7 @@ core.register_chatcommand("unban", {
858860
})
859861

860862
core.register_chatcommand("kick", {
861-
params = "<name> [reason]",
863+
params = "<name> [<reason>]",
862864
description = "Kick a player",
863865
privs = {kick=true},
864866
func = function(name, param)
@@ -877,7 +879,7 @@ core.register_chatcommand("kick", {
877879
})
878880

879881
core.register_chatcommand("clearobjects", {
880-
params = "[full|quick]",
882+
params = "[full | quick]",
881883
description = "Clear all objects in world",
882884
privs = {server=true},
883885
func = function(name, param)
@@ -923,7 +925,7 @@ core.register_chatcommand("msg", {
923925
})
924926

925927
core.register_chatcommand("last-login", {
926-
params = "[name]",
928+
params = "[<name>]",
927929
description = "Get the last login time of a player",
928930
func = function(name, param)
929931
if param == "" then
@@ -940,7 +942,7 @@ core.register_chatcommand("last-login", {
940942
})
941943

942944
core.register_chatcommand("clearinv", {
943-
params = "[name]",
945+
params = "[<name>]",
944946
description = "Clear the inventory of yourself or another player",
945947
func = function(name, param)
946948
local player

0 commit comments

Comments
 (0)
Please sign in to comment.