12 :
Command(commandController_, name_)
18 assert(infoTopics.empty());
24 if (infoTopics.contains(topic.
getName())) {
25 std::cerr <<
"INTERNAL ERROR: already have an info topic with "
26 "name " << topic.
getName() <<
'\n';
30 infoTopics.insert_noDuplicateCheck(&topic);
35 if (!infoTopics.contains(topic.
getName())) {
36 std::cerr <<
"INTERNAL ERROR: can't unregister topic with name "
37 << topic.
getName() <<
", not found!\n";
40 infoTopics.erase(topic.
getName());
45void InfoCommand::execute(std::span<const TclObject> tokens,
48 switch (tokens.size()) {
52 infoTopics, [](
auto*
t) {
return t->getName(); }));
56 assert(tokens.size() >= 2);
57 const auto& topic = tokens[1].getString();
58 auto it = infoTopics.find(topic);
59 if (it ==
end(infoTopics)) {
60 throw CommandException(
"No info on: ", topic);
62 (*it)->execute(tokens, result);
67std::string InfoCommand::help(std::span<const TclObject> tokens)
const
70 switch (tokens.size()) {
73 result =
"Show info on a certain topic\n"
74 " info [topic] [...]\n";
78 assert(tokens.size() >= 2);
79 auto topic = tokens[1].getString();
80 auto it = infoTopics.find(topic);
81 if (it ==
end(infoTopics)) {
82 throw CommandException(
"No info on: ", topic);
84 result = (*it)->help(tokens);
90void InfoCommand::tabCompletion(std::vector<std::string>& tokens)
const
92 switch (tokens.size()) {
96 [](
auto*
t) -> std::string_view {
return t->getName(); }));
101 assert(tokens.size() >= 3);
102 if (
auto it = infoTopics.find(tokens[1]); it !=
end(infoTopics)) {
103 (*it)->tabCompletion(tokens);
static void completeString(std::vector< std::string > &tokens, ITER begin, ITER end, bool caseSensitive=true)
const std::string & getName() const
void unregisterTopic(const InfoTopic &topic)
void registerTopic(const InfoTopic &topic)
InfoCommand(CommandController &commandController, const std::string &name)
void addListElements(ITER first, ITER last)
This file implemented 3 utility functions:
constexpr auto transform(Range &&range, UnaryOp op)
constexpr auto end(const zstring_view &x)