From: Maksym Mykhailov -X (mmykhail - SOFTSERVE INC at Cisco) Date: Mon, 30 Sep 2024 19:26:04 +0000 (+0000) Subject: Pull request #4447: main: change help command to print in alphabetical order. X-Git-Tag: 3.4.0.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d76827e9550bbfc869d468b1210823e1785b3419;p=thirdparty%2Fsnort3.git Pull request #4447: main: change help command to print in alphabetical order. Merge in SNORT/snort3 from ~MMYKHAIL/snort3:help_commands to master Squashed commit of the following: commit 8a8144228ce38a2395be33cf5509b6a2847aeae9 Author: Maksym Mykhailov Date: Thu Sep 12 09:31:58 2024 -0400 main: change help command to print in alphabetical order. --- diff --git a/src/main.cc b/src/main.cc index 86c059c50..b6b03373a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -816,6 +816,9 @@ int main_help(lua_State* L) { ControlConn* ctrlcon = ControlConn::query_from_lua(L); std::list modules = ModuleManager::get_all_modules(); + std::set no_prefix_cmds; + std::set prefix_cmds; + for (const auto& m : modules) { const Command* cmd = m->get_commands(); @@ -835,10 +838,22 @@ int main_help(lua_State* L) info += ": "; info += cmd->help; info += "\n"; - send_response(ctrlcon, info.c_str()); + if (prefix.empty()) + no_prefix_cmds.emplace(info); + else + prefix_cmds.emplace(info); ++cmd; } } + + send_response(ctrlcon, "\nModule Commands:\n"); + for (const auto& str : prefix_cmds) + send_response(ctrlcon, str.c_str()); + + send_response(ctrlcon, "\nTop Level Commands:\n"); + for (const auto& str : no_prefix_cmds) + send_response(ctrlcon, str.c_str()); + return 0; }