From 8058a9385a3cb93d970967ec8ddd5332a086816d Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 8 Mar 2021 16:00:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83cmd=E7=9A=84=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=92=8C=E9=83=A8=E5=88=86=E5=87=BD=E6=95=B0=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_cmd.lua | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/parts/scenes/app_cmd.lua b/parts/scenes/app_cmd.lua index ab7a4de3..da128740 100644 --- a/parts/scenes/app_cmd.lua +++ b/parts/scenes/app_cmd.lua @@ -68,14 +68,11 @@ userG.the_box=first_box local commands={} --Basic commands do--commands.help(arg) - -- command_help_messages format: - -- command_help_messages is a table - -- key: the command - -- value: a table containing the following two elements: - -- description: a string that shows when user types `help` or - -- `help [page]`. - -- details: an array of strings, each representing a line, that shows - -- when user types `help [command]`. + --format of table command_help_messages: + -- key: the command + -- value: a table containing the following two elements: + -- description: a string that shows when user types `help` or `help [page]`. + -- details: an array of strings containing documents, shows when user types `help [command]`. local command_help_messages={ help={ description="Display help messages.", @@ -86,8 +83,7 @@ do--commands.help(arg) "", "Usage:", "help", - "help [page]", - "help [command_name]", + "help [page|command_name]", }, }, ["?"]="help", @@ -218,10 +214,7 @@ do--commands.help(arg) details={ "Load a theme.", "", - "Usage: theme [theme_name]", - "", - "Available themes:", - "classic|xmas|sprfes|zday", + "Usage: theme ", }, }, }TABLE.reIndex(command_help_messages) @@ -247,7 +240,7 @@ do--commands.help(arg) local pageSize=10 local maxPage=math.ceil(#command_help_list/pageSize) function commands.help(arg) - -- help [command] + --help [command] if command_help_messages[arg]then for _,v in ipairs(command_help_messages[arg].details)do log(v) @@ -255,7 +248,7 @@ do--commands.help(arg) return end - -- help or help [page] + --help or help [page] arg=tonumber(arg) if arg and arg>=1 and arg<=maxPage then log"Use help [page] to view more commands," @@ -266,9 +259,11 @@ do--commands.help(arg) 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)."} + return end + + --Else + log{COLOR.red,"Invalid page number. Must be between 1 and "..maxPage.." (inclusive)."} end end function commands.shutdown(arg)os.execute("shutdown "..arg)end