From 16b1f474c4c14dfecb5ff2ac6875703d84915bc7 Mon Sep 17 00:00:00 2001 From: neru Date: Tue, 13 May 2025 00:41:20 -0300 Subject: [PATCH] feat: add help command functionality --- lua/CC Tweaked/tutel/tutel-host.lua | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lua/CC Tweaked/tutel/tutel-host.lua b/lua/CC Tweaked/tutel/tutel-host.lua index 3bad573..b28e803 100644 --- a/lua/CC Tweaked/tutel/tutel-host.lua +++ b/lua/CC Tweaked/tutel/tutel-host.lua @@ -366,16 +366,28 @@ end registerConsoleCommand("turtles", turtlesCommand, "Lists all the linked turtles") function helpCommand(args) - 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) + if #args == 0 then + log.info("----- commands -----") + for _, cmd in pairs(consoleCommands) do + 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