Merge pull request #6614

fb31167b1 Wallet, daemon: From 'help_advanced' back to 'help', and new 'apropos' command (rbrunner7)
This commit is contained in:
Alexander Blair 2020-08-16 12:44:03 -07:00
commit c6c4ead44e
No known key found for this signature in database
GPG key ID: C64552D877C32479
7 changed files with 135 additions and 49 deletions

View file

@ -543,6 +543,31 @@ eof:
return it->second.second;
}
std::vector<std::string> get_command_list(const std::vector<std::string>& keywords = std::vector<std::string>())
{
std::vector<std::string> list;
list.reserve(m_command_handlers.size());
for(auto const& x:m_command_handlers)
{
bool take = true;
for(auto const& y:keywords)
{
bool in_usage = x.second.second.first.find(y) != std::string::npos;
bool in_description = x.second.second.second.find(y) != std::string::npos;
if (!(in_usage || in_description))
{
take = false;
break;
}
}
if (take)
{
list.push_back(x.first);
}
}
return list;
}
void set_handler(const std::string& cmd, const callback& hndlr, const std::string& usage = "", const std::string& description = "")
{
lookup::mapped_type & vt = m_command_handlers[cmd];