Changeset

13683:4c1f26b4883b 13.0

mod_admin_shell: Support for hiding certain commands from default help listing Useful for e.g. deprecated commands.
author Matthew Wild <mwild1@gmail.com>
date Thu, 13 Feb 2025 16:16:19 +0000
parents 13682:0055c177a54c
children 13684:026a75a443de
files plugins/mod_admin_shell.lua
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua	Thu Feb 13 16:15:16 2025 +0000
+++ b/plugins/mod_admin_shell.lua	Thu Feb 13 16:16:19 2025 +0000
@@ -349,7 +349,7 @@
 	return true;
 end);
 
-local function describe_command(s)
+local function describe_command(s, hidden)
 	local section, name, args, desc = s:match("^([%w_]+):([%w_]+)%(([^)]*)%) %- (.+)$");
 	if not section then
 		error("Failed to parse command description: "..s);
@@ -360,6 +360,7 @@
 		args = array.collect(args:gmatch("[%w_]+")):map(function (arg_name)
 			return { name = arg_name };
 		end);
+		hidden = hidden;
 	};
 end
 
@@ -455,10 +456,12 @@
 				end
 
 				for command, command_help in it.sorted_pairs(section_help.commands or {}) do
-					c = c + 1;
-					local args = array.pluck(command_help.args, "name"):concat(", ");
-					local desc = command_help.desc or command_help.module and ("Provided by mod_"..command_help.module) or "";
-					print(("%s:%s(%s) - %s"):format(section_name, command, args, desc));
+					if not command_help.hidden then
+						c = c + 1;
+						local args = array.pluck(command_help.args, "name"):concat(", ");
+						local desc = command_help.desc or command_help.module and ("Provided by mod_"..command_help.module) or "";
+						print(("%s:%s(%s) - %s"):format(section_name, command, args, desc));
+					end
 				end
 			elseif help_topics[section_name] then
 				local topic = help_topics[section_name];