feat: add usage
This commit is contained in:
@@ -267,11 +267,12 @@ registerEventListener("key", scrollLogs)
|
|||||||
local consoleCommands = {}
|
local consoleCommands = {}
|
||||||
local commandBuffer = ""
|
local commandBuffer = ""
|
||||||
|
|
||||||
function registerConsoleCommand(name, handler, desc)
|
function registerConsoleCommand(name, handler, desc, usage)
|
||||||
local cmd = {
|
local cmd = {
|
||||||
["name"] = name,
|
["name"] = name,
|
||||||
["handler"] = handler,
|
["handler"] = handler,
|
||||||
["desc"] = desc or ""
|
["desc"] = desc or "",
|
||||||
|
["usage"] = usage or nil
|
||||||
}
|
}
|
||||||
consoleCommands[name] = cmd
|
consoleCommands[name] = cmd
|
||||||
end
|
end
|
||||||
@@ -324,7 +325,7 @@ function echoCommand(args)
|
|||||||
log.info(table.concat(args, " "))
|
log.info(table.concat(args, " "))
|
||||||
end
|
end
|
||||||
|
|
||||||
registerConsoleCommand("echo", echoCommand, "Prints your message")
|
registerConsoleCommand("echo", echoCommand, "Prints your message", "echo (string)")
|
||||||
|
|
||||||
function exitCommand(args)
|
function exitCommand(args)
|
||||||
shouldRun = false
|
shouldRun = false
|
||||||
@@ -339,13 +340,13 @@ end
|
|||||||
|
|
||||||
registerConsoleCommand("scan", scanCommand, "Sends out a scan command to pair unlinked turtles")
|
registerConsoleCommand("scan", scanCommand, "Sends out a scan command to pair unlinked turtles")
|
||||||
|
|
||||||
function clearCommand()
|
function clearCommand(args)
|
||||||
log.buffer = {}
|
log.buffer = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
registerConsoleCommand("clear", clearCommand, "Clears the console")
|
registerConsoleCommand("clear", clearCommand, "Clears the console")
|
||||||
|
|
||||||
function turtlesCommand()
|
function turtlesCommand(args)
|
||||||
if #turtles == 0 then
|
if #turtles == 0 then
|
||||||
log.info("no turtles registered")
|
log.info("no turtles registered")
|
||||||
return
|
return
|
||||||
@@ -364,11 +365,14 @@ end
|
|||||||
|
|
||||||
registerConsoleCommand("turtles", turtlesCommand, "Lists all the linked turtles")
|
registerConsoleCommand("turtles", turtlesCommand, "Lists all the linked turtles")
|
||||||
|
|
||||||
function helpCommand()
|
function helpCommand(args)
|
||||||
log.info("----- commands -----")
|
log.info("----- commands -----")
|
||||||
for _, cmd in pairs(consoleCommands) do
|
for _, cmd in pairs(consoleCommands) do
|
||||||
log.info("* %s", cmd.name)
|
log.info("* %s", cmd.name)
|
||||||
log.info("\t%s", cmd.desc)
|
log.info("\t\t%s", cmd.desc)
|
||||||
|
if cmd.usage then
|
||||||
|
log.info("Usage: %s", cmd.usage)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
registerConsoleCommand("help", helpCommand, "Prints out all the console commands")
|
registerConsoleCommand("help", helpCommand, "Prints out all the console commands")
|
||||||
|
|||||||
Reference in New Issue
Block a user