console: lambda append_csv per a generateConsoleHelp
This commit is contained in:
@@ -1275,12 +1275,17 @@ auto CommandRegistry::generateTerminalHelp() const -> std::string {
|
|||||||
return out.str();
|
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
|
// Agrupar comandos visibles por scope
|
||||||
std::string global_cmds;
|
std::string global_cmds;
|
||||||
std::string debug_cmds;
|
std::string debug_cmds;
|
||||||
std::string editor_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_) {
|
for (const auto& cmd : commands_) {
|
||||||
if (cmd.help_hidden) { continue; }
|
if (cmd.help_hidden) { continue; }
|
||||||
if (!isCommandVisible(cmd)) { continue; }
|
if (!isCommandVisible(cmd)) { continue; }
|
||||||
@@ -1290,16 +1295,12 @@ auto CommandRegistry::generateConsoleHelp() const -> std::string { // NOLINT(re
|
|||||||
|
|
||||||
// Clasificar por el PRIMER scope del comando
|
// Clasificar por el PRIMER scope del comando
|
||||||
const std::string& primary = cmd.scopes.empty() ? "global" : cmd.scopes[0];
|
const std::string& primary = cmd.scopes.empty() ? "global" : cmd.scopes[0];
|
||||||
|
|
||||||
if (primary == "editor") {
|
if (primary == "editor") {
|
||||||
if (!editor_cmds.empty()) { editor_cmds += ", "; }
|
append_csv(editor_cmds, kw_lower);
|
||||||
editor_cmds += kw_lower;
|
|
||||||
} else if (primary == "debug") {
|
} else if (primary == "debug") {
|
||||||
if (!debug_cmds.empty()) { debug_cmds += ", "; }
|
append_csv(debug_cmds, kw_lower);
|
||||||
debug_cmds += kw_lower;
|
|
||||||
} else {
|
} else {
|
||||||
if (!global_cmds.empty()) { global_cmds += ", "; }
|
append_csv(global_cmds, kw_lower);
|
||||||
global_cmds += kw_lower;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user