Skip to content

Commit 96eb35f

Browse files
committed
docs: engine help now also displays standard UCI commands (#507)
1 parent 948de60 commit 96eb35f

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

libbenbot/src/engine/Printing.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <libbenbot/search/Result.hpp>
2424
#include <libchess/notation/FEN.hpp>
2525
#include <libchess/notation/MoveFormats.hpp>
26+
#include <libchess/uci/EngineBase.hpp>
2627
#include <libchess/uci/Printing.hpp>
2728
#include <libutil/Strings.hpp>
2829
#include <libutil/TextTable.hpp>
@@ -46,6 +47,26 @@ auto Engine::get_name() const -> std::string
4647
return std::format("BenBot {}", resources::get_version_string());
4748
}
4849

50+
namespace {
51+
void print_command_table(const uci::EngineBase::CommandList commands)
52+
{
53+
TextTable table;
54+
55+
table.append_column("Command")
56+
.append_column("Notes");
57+
58+
for (const auto& command : commands) {
59+
table.new_row()
60+
.append_column(std::format("{} {}", command.name, command.argsHelp))
61+
.append_column(command.description);
62+
}
63+
64+
print_colored_table(table);
65+
66+
std::cout.flush();
67+
}
68+
} // namespace
69+
4970
void Engine::print_help(const string_view args) const
5071
{
5172
const bool noLogo = [args] {
@@ -61,25 +82,16 @@ void Engine::print_help(const string_view args) const
6182
println("");
6283
}
6384

64-
println(
65-
"All standard UCI commands are supported, as well as the following non-standard commands:");
66-
85+
println("The following standard UCI commands are supported:");
6786
println("");
6887

69-
TextTable table;
70-
71-
table.append_column("Command")
72-
.append_column("Notes");
73-
74-
for (const auto& command : customCommands) {
75-
table.new_row()
76-
.append_column(std::format("{} {}", command.name, command.argsHelp))
77-
.append_column(command.description);
78-
}
88+
print_command_table(get_standard_uci_commands());
89+
println("");
7990

80-
print_colored_table(table);
91+
println("The following non-standard UCI commands are supported:");
92+
println("");
8193

82-
std::cout.flush();
94+
print_command_table(customCommands);
8395
}
8496

8597
void Engine::print_options() const

libchess/include/libchess/uci/EngineBase.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct EngineBase {
247247
.name = "go",
248248
.action = [this](const string_view args) { go(parse_go_options(args, position)); },
249249
.description = "Start a search",
250-
.argsHelp = "Refer to UCI spec for full options" },
250+
.argsHelp = { } },
251251
EngineCommand {
252252
.name = "setoption",
253253
.action = [this](const string_view args) { handle_setoption(args); },
@@ -264,7 +264,7 @@ struct EngineBase {
264264
handle_registration(parse_register_options(args));
265265
},
266266
.description = "Handle license registration",
267-
.argsHelp = "Refer to UCI spec" }
267+
.argsHelp = { } }
268268
};
269269
};
270270

0 commit comments

Comments
 (0)