From 4e9d7e1450a9bbca9f34ec136c602ffe1039f135 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 17 May 2026 13:36:22 +0200 Subject: [PATCH] console: lambda append_csv per a generateConsoleHelp --- source/game/ui/console_commands.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/game/ui/console_commands.cpp b/source/game/ui/console_commands.cpp index 970e754..304771e 100644 --- a/source/game/ui/console_commands.cpp +++ b/source/game/ui/console_commands.cpp @@ -1275,12 +1275,17 @@ auto CommandRegistry::generateTerminalHelp() const -> std::string { return out.str(); } -auto CommandRegistry::generateConsoleHelp() const -> std::string { // NOLINT(readability-function-cognitive-complexity) +auto CommandRegistry::generateConsoleHelp() const -> std::string { // Agrupar comandos visibles por scope std::string global_cmds; std::string debug_cmds; std::string editor_cmds; + auto append_csv = [](std::string& dst, const std::string& token) { + if (!dst.empty()) { dst += ", "; } + dst += token; + }; + for (const auto& cmd : commands_) { if (cmd.help_hidden) { continue; } if (!isCommandVisible(cmd)) { continue; } @@ -1290,16 +1295,12 @@ auto CommandRegistry::generateConsoleHelp() const -> std::string { // NOLINT(re // Clasificar por el PRIMER scope del comando const std::string& primary = cmd.scopes.empty() ? "global" : cmd.scopes[0]; - if (primary == "editor") { - if (!editor_cmds.empty()) { editor_cmds += ", "; } - editor_cmds += kw_lower; + append_csv(editor_cmds, kw_lower); } else if (primary == "debug") { - if (!debug_cmds.empty()) { debug_cmds += ", "; } - debug_cmds += kw_lower; + append_csv(debug_cmds, kw_lower); } else { - if (!global_cmds.empty()) { global_cmds += ", "; } - global_cmds += kw_lower; + append_csv(global_cmds, kw_lower); } }