微调cmd的注释和部分函数说明
This commit is contained in:
@@ -68,14 +68,11 @@ userG.the_box=first_box
|
|||||||
local commands={}
|
local commands={}
|
||||||
--Basic commands
|
--Basic commands
|
||||||
do--commands.help(arg)
|
do--commands.help(arg)
|
||||||
-- command_help_messages format:
|
--format of table command_help_messages:
|
||||||
-- command_help_messages is a table
|
-- key: the command
|
||||||
-- key: the command
|
-- value: a table containing the following two elements:
|
||||||
-- value: a table containing the following two elements:
|
-- description: a string that shows when user types `help` or `help [page]`.
|
||||||
-- description: a string that shows when user types `help` or
|
-- details: an array of strings containing documents, shows when user types `help [command]`.
|
||||||
-- `help [page]`.
|
|
||||||
-- details: an array of strings, each representing a line, that shows
|
|
||||||
-- when user types `help [command]`.
|
|
||||||
local command_help_messages={
|
local command_help_messages={
|
||||||
help={
|
help={
|
||||||
description="Display help messages.",
|
description="Display help messages.",
|
||||||
@@ -86,8 +83,7 @@ do--commands.help(arg)
|
|||||||
"",
|
"",
|
||||||
"Usage:",
|
"Usage:",
|
||||||
"help",
|
"help",
|
||||||
"help [page]",
|
"help [page|command_name]",
|
||||||
"help [command_name]",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
["?"]="help",
|
["?"]="help",
|
||||||
@@ -218,10 +214,7 @@ do--commands.help(arg)
|
|||||||
details={
|
details={
|
||||||
"Load a theme.",
|
"Load a theme.",
|
||||||
"",
|
"",
|
||||||
"Usage: theme [theme_name]",
|
"Usage: theme <classic|xmas|sprfes|zday>",
|
||||||
"",
|
|
||||||
"Available themes:",
|
|
||||||
"classic|xmas|sprfes|zday",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}TABLE.reIndex(command_help_messages)
|
}TABLE.reIndex(command_help_messages)
|
||||||
@@ -247,7 +240,7 @@ do--commands.help(arg)
|
|||||||
local pageSize=10
|
local pageSize=10
|
||||||
local maxPage=math.ceil(#command_help_list/pageSize)
|
local maxPage=math.ceil(#command_help_list/pageSize)
|
||||||
function commands.help(arg)
|
function commands.help(arg)
|
||||||
-- help [command]
|
--help [command]
|
||||||
if command_help_messages[arg]then
|
if command_help_messages[arg]then
|
||||||
for _,v in ipairs(command_help_messages[arg].details)do
|
for _,v in ipairs(command_help_messages[arg].details)do
|
||||||
log(v)
|
log(v)
|
||||||
@@ -255,7 +248,7 @@ do--commands.help(arg)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- help or help [page]
|
--help or help [page]
|
||||||
arg=tonumber(arg)
|
arg=tonumber(arg)
|
||||||
if arg and arg>=1 and arg<=maxPage then
|
if arg and arg>=1 and arg<=maxPage then
|
||||||
log"Use help [page] to view more commands,"
|
log"Use help [page] to view more commands,"
|
||||||
@@ -266,9 +259,11 @@ do--commands.help(arg)
|
|||||||
local cmd=command_help_list[i]
|
local cmd=command_help_list[i]
|
||||||
log{COLOR.W,cmd,COLOR.grey," "..command_help_messages[cmd].description}
|
log{COLOR.W,cmd,COLOR.grey," "..command_help_messages[cmd].description}
|
||||||
end
|
end
|
||||||
else
|
return
|
||||||
log{COLOR.red,"Invalid page number. Must be between 1 and "..maxPage.." (inclusive)."}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Else
|
||||||
|
log{COLOR.red,"Invalid page number. Must be between 1 and "..maxPage.." (inclusive)."}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function commands.shutdown(arg)os.execute("shutdown "..arg)end
|
function commands.shutdown(arg)os.execute("shutdown "..arg)end
|
||||||
|
|||||||
Reference in New Issue
Block a user