cmd中help命令的解析更清晰

This commit is contained in:
MrZ626
2021-03-10 19:20:28 +08:00
parent e8c471c059
commit 28fd42fdd3

View File

@@ -213,21 +213,25 @@ do--commands.help(arg)
end end
--help or help [page] --help or help [page]
if arg==""then arg=1 else arg=tonumber(arg)end local page=arg==""and 1 or tonumber(arg)
if arg and arg==int(arg)and arg>=1 and arg<=maxPage then if page then
log"Use help [page] to view more commands," if arg==int(arg)and arg>=1 and arg<=maxPage then
log"or help [command_name] for details of a command." log"Use help [page] to view more commands,"
log"" log"or help [command_name] for details of a command."
log{COLOR.lPink,"Page ",COLOR.lG,arg,COLOR.lPink," of ",COLOR.lG,maxPage} log""
for i=pageSize*(arg-1)+1,math.min(pageSize*arg,#command_help_list)do log{COLOR.lPink,"Page ",COLOR.lG,arg,COLOR.lPink," of ",COLOR.lG,maxPage}
local cmd=command_help_list[i] for i=pageSize*(arg-1)+1,math.min(pageSize*arg,#command_help_list)do
log{COLOR.W,cmd,COLOR.grey," "..command_help_messages[cmd].description} local cmd=command_help_list[i]
log{COLOR.W,cmd,COLOR.grey," "..command_help_messages[cmd].description}
end
else
log{COLOR.red,"Invalid page number. Must be between 1 and "..maxPage.." (inclusive)."}
end end
return else
log{COLOR.red,"No cammand called "..arg}
end end
--Else --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