Compare commits

...

2 Commits

Author SHA1 Message Date
neru 60db9abb31 style: consistent casing 2025-05-13 00:42:05 -03:00
neru 16b1f474c4 feat: add help command functionality 2025-05-13 00:41:20 -03:00
+18 -6
View File
@@ -213,7 +213,7 @@ function handleMessages(side, channel, replyChannel, message, dist)
-- cmd validation
if not message.name then
log.warning("received nameless command?")
log.warning("Received nameless command?")
return
end
@@ -366,16 +366,28 @@ end
registerConsoleCommand("turtles", turtlesCommand, "Lists all the linked turtles")
function helpCommand(args)
if #args == 0 then
log.info("----- commands -----")
for _, cmd in pairs(consoleCommands) do
log.info("* %s", cmd.name)
log.info("* > %s", cmd.desc)
if cmd.usage then
log.info("* > Usage: %s", cmd.usage)
log.info("%s - %s", cmd.name, cmd.desc)
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
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