Comparison

prosodyctl @ 11582:a3d48204ec95

prosodyctl: Reorganize help / command list
author Kim Alvefur <zash@zash.se>
date Fri, 22 Jan 2021 00:11:39 +0100
parent 11563:0983653cbfdf
child 11587:ce7c52a6d650
comparison
equal deleted inserted replaced
11581:7e111f7147dc 11582:a3d48204ec95
641 end 641 end
642 end 642 end
643 643
644 if not commands[command] then -- Show help for all commands 644 if not commands[command] then -- Show help for all commands
645 function show_usage(usage, desc) 645 function show_usage(usage, desc)
646 print(" "..usage); 646 print(string.format(" %-11s %s", usage, desc));
647 print(" "..desc);
648 end 647 end
649 648
650 print("prosodyctl - Manage a Prosody server"); 649 print("prosodyctl - Manage a Prosody server");
651 print(""); 650 print("");
652 print("Usage: "..arg[0].." COMMAND [OPTIONS]"); 651 print("Usage: "..arg[0].." COMMAND [OPTIONS]");
653 print(""); 652 print("");
654 print("Where COMMAND may be one of:\n"); 653 print("Where COMMAND may be one of:");
655 654
656 local hidden_commands = require "util.set".new{ "register", "unregister" }; 655 local hidden_commands = require "util.set".new{ "register", "unregister" };
657 local commands_order = { "install", "remove", "list", "adduser", "passwd", "deluser", "start", "stop", "restart", "reload", 656 local commands_order = {
658 "about" }; 657 "Plugin management:",
658 "install"; "remove"; "list";
659 "User management:",
660 "adduser"; "passwd"; "deluser";
661 "Process management:",
662 "start"; "stop"; "restart"; "reload"; "status";
663 "Informative:",
664 "about",
665 };
659 666
660 local done = {}; 667 local done = {};
661 668
662 for _, command_name in ipairs(commands_order) do 669 for _, command_name in ipairs(commands_order) do
663 local command_func = commands[command_name]; 670 local command_func = commands[command_name];
664 if command_func then 671 if command_func then
665 command_func{ "--help" }; 672 command_func{ "--help" };
673 done[command_name] = true;
674 else
666 print"" 675 print""
667 done[command_name] = true; 676 print(command_name);
668 end 677 end
669 end 678 end
670 679
671 for command_name, command_func in pairs(commands) do 680 for command_name, command_func in pairs(commands) do
672 if not done[command_name] and not hidden_commands:contains(command_name) then 681 if not done[command_name] and not hidden_commands:contains(command_name) then
673 command_func{ "--help" }; 682 command_func{ "--help" };
674 print""
675 done[command_name] = true; 683 done[command_name] = true;
676 end 684 end
677 end 685 end
678 686
679 687