aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/command_server.cpp
diff options
context:
space:
mode:
authorrbrunner7 <rbrunner@dreamshare.ch>2020-06-01 10:20:59 +0200
committerrbrunner7 <rbrunner@dreamshare.ch>2020-07-24 07:12:11 +0200
commitfb31167b12caccdac071bdbe5ad58f235cdb82fe (patch)
treef4ccd86e7fe5347ce8e9e21a36bdba2d976d2414 /src/daemon/command_server.cpp
parentMerge pull request #6586 (diff)
downloadmonero-fb31167b12caccdac071bdbe5ad58f235cdb82fe.tar.xz
Wallet, daemon: From 'help_advanced' back to 'help', and new 'apropos' command
Diffstat (limited to '')
-rw-r--r--src/daemon/command_server.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index b335116de..ac4c30726 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -58,6 +58,12 @@ t_command_server::t_command_server(
, "Show the help section or the documentation about a <command>."
);
m_command_lookup.set_handler(
+ "apropos"
+ , std::bind(&t_command_server::apropos, this, p::_1)
+ , "apropos <keyword> [<keyword> ...]"
+ , "Search all command descriptions for keyword(s)."
+ );
+ m_command_lookup.set_handler(
"print_height"
, std::bind(&t_command_parser_executor::print_height, &m_parser, p::_1)
, "Print the local blockchain height."
@@ -349,7 +355,7 @@ bool t_command_server::start_handling(std::function<void(void)> exit_handler)
{
if (m_is_rpc) return false;
- m_command_lookup.start_handling("", get_commands_str(), exit_handler);
+ m_command_lookup.start_handling("", "Use \"help\" to list all commands and their usage\n", exit_handler);
return true;
}
@@ -374,6 +380,33 @@ bool t_command_server::help(const std::vector<std::string>& args)
return true;
}
+bool t_command_server::apropos(const std::vector<std::string>& args)
+{
+ if (args.empty())
+ {
+ std::cout << "Missing keyword" << std::endl;
+ return true;
+ }
+ const std::vector<std::string>& command_list = m_command_lookup.get_command_list(args);
+ if (command_list.empty())
+ {
+ std::cout << "Nothing found" << std::endl;
+ return true;
+ }
+
+ std::cout << std::endl;
+ for(auto const& command:command_list)
+ {
+ std::vector<std::string> cmd;
+ cmd.push_back(command);
+ std::pair<std::string, std::string> documentation = m_command_lookup.get_documentation(cmd);
+ std::cout << " " << documentation.first << std::endl;
+ }
+ std::cout << std::endl;
+
+ return true;
+}
+
std::string t_command_server::get_commands_str()
{
std::stringstream ss;
@@ -382,7 +415,7 @@ std::string t_command_server::get_commands_str()
std::string usage = m_command_lookup.get_usage();
boost::replace_all(usage, "\n", "\n ");
usage.insert(0, " ");
- ss << usage << std::endl;
+ ss << usage;
return ss.str();
}