Comparison

plugins/mod_admin_shell.lua @ 13737:46e7cc4de5e6 13.0

mod_admin_shell: Improve help listing in non-REPL mode
author Matthew Wild <mwild1@gmail.com>
date Mon, 17 Feb 2025 19:10:48 +0000
parent 13736:42367f7e6e94
child 13769:5cc4a3e0335c
comparison
equal deleted inserted replaced
13736:42367f7e6e94 13737:46e7cc4de5e6
563 end 563 end
564 564
565 for command, command_help in it.sorted_pairs(section_help.commands or {}) do 565 for command, command_help in it.sorted_pairs(section_help.commands or {}) do
566 if not command_help.hidden then 566 if not command_help.hidden then
567 c = c + 1; 567 c = c + 1;
568 local args = array.pluck(command_help.args, "name"):concat(", ");
569 local desc = command_help.desc or command_help.module and ("Provided by mod_"..command_help.module) or ""; 568 local desc = command_help.desc or command_help.module and ("Provided by mod_"..command_help.module) or "";
570 print(("%s:%s(%s) - %s"):format(section_name, command, args, desc)); 569 if self.session.repl then
570 local args = array.pluck(command_help.args, "name"):concat(", ");
571 print(("%s:%s(%s) - %s"):format(section_name, command, args, desc));
572 else
573 local args = array.pluck(command_help.args, "name"):concat("> <");
574 if args ~= "" then
575 args = "<"..args..">";
576 end
577 print(("%s %s %s"):format(section_name, command, args));
578 print((" %s"):format(desc));
579 if command_help.flags then
580 local flags = command_help.flags;
581 print("");
582 print((" Flags:"));
583
584 if flags.kv_params then
585 for name in it.sorted_pairs(flags.kv_params) do
586 print(" --"..name:gsub("_", "-"));
587 end
588 end
589
590 if flags.value_params then
591 for name in it.sorted_pairs(flags.value_params) do
592 print(" --"..name:gsub("_", "-").." <"..name..">");
593 end
594 end
595
596 if flags.array_params then
597 for name in it.sorted_pairs(flags.array_params) do
598 print(" --"..name:gsub("_", "-").." <"..name..">, ...");
599 end
600 end
601
602 end
603 print("");
604 end
571 end 605 end
572 end 606 end
573 elseif help_topics[section_name] then 607 elseif help_topics[section_name] then
574 local topic = help_topics[section_name]; 608 local topic = help_topics[section_name];
575 if type(topic.content) == "function" then 609 if type(topic.content) == "function" then