feat: add help command functionality
This commit is contained in:
@@ -366,16 +366,28 @@ end
|
|||||||
registerConsoleCommand("turtles", turtlesCommand, "Lists all the linked turtles")
|
registerConsoleCommand("turtles", turtlesCommand, "Lists all the linked turtles")
|
||||||
|
|
||||||
function helpCommand(args)
|
function helpCommand(args)
|
||||||
log.info("----- commands -----")
|
if #args == 0 then
|
||||||
for _, cmd in pairs(consoleCommands) do
|
log.info("----- commands -----")
|
||||||
log.info("* %s", cmd.name)
|
for _, cmd in pairs(consoleCommands) do
|
||||||
log.info("* > %s", cmd.desc)
|
log.info("%s - %s", cmd.name, cmd.desc)
|
||||||
if cmd.usage then
|
|
||||||
log.info("* > Usage: %s", cmd.usage)
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
local cmdName = args[1]
|
||||||
|
local cmd = consoleCommands[cmdName]
|
||||||
|
|
||||||
|
if not cmdName then
|
||||||
|
log.error("Unable to find command: %s", cmdName)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
log.info("---- %s ----", cmdName)
|
||||||
|
log.info(cmd.desc)
|
||||||
|
log.info("Usage %s:", cmd.usage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
registerConsoleCommand("help", helpCommand, "Prints out all the console commands")
|
|
||||||
|
registerConsoleCommand("help", helpCommand, "Prints out all the console commands or usage of a specified command",
|
||||||
|
"help or help (command name)")
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
drawing functions
|
drawing functions
|
||||||
|
|||||||
Reference in New Issue
Block a user