19 :
Command(commandController, name)
25 assert(infoTopics.
empty());
31 if (infoTopics.
find(name) != infoTopics.
end()) {
32 std::cerr <<
"INTERNAL ERROR: already have a info topic with "
33 "name " << name << std::endl;
37 infoTopics[name] = &topic;
43 if (infoTopics.
find(name) == infoTopics.
end()) {
44 std::cerr <<
"INTERNAL ERROR: can't unregister topic with name "
45 "name " << name <<
", not found!" << std::endl;
48 assert(infoTopics[name] == &topic);
49 infoTopics.
erase(name);
54 void InfoCommand::execute(
const vector<TclObject>& tokens,
57 switch (tokens.size()) {
60 for (
auto& p : infoTopics) {
66 assert(tokens.size() >= 2);
67 const auto& topic = tokens[1].getString();
68 auto it = infoTopics.find(topic);
69 if (it == infoTopics.end()) {
70 throw CommandException(
"No info on: " + topic);
72 it->second->execute(tokens, result);
77 string InfoCommand::help(
const vector<string>& tokens)
const
80 switch (tokens.size()) {
83 result =
"Show info on a certain topic\n"
84 " info [topic] [...]\n";
88 assert(tokens.size() >= 2);
89 auto it = infoTopics.find(tokens[1]);
90 if (it == infoTopics.end()) {
91 throw CommandException(
"No info on: " + tokens[1]);
93 result = it->second->help(tokens);
99 void InfoCommand::tabCompletion(vector<string>& tokens)
const
101 switch (tokens.size()) {
109 assert(tokens.size() >= 3);
110 auto it = infoTopics.find(tokens[1]);
111 if (it != infoTopics.end()) {
112 it->second->tabCompletion(tokens);