diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-01-28 21:34:17 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-01-28 21:34:17 +0200 |
commit | 23c7663167d9d0000e782d3b3f1423b942347431 (patch) | |
tree | bf9ff57fd654db8489374f97f30f5a2796f9e90d /src/daemon/command_parser_executor.cpp | |
parent | Merge pull request #5079 (diff) | |
parent | daemon: extend 'print_pl' command, optional filter by type and limit (diff) | |
download | monero-23c7663167d9d0000e782d3b3f1423b942347431.tar.xz |
Merge pull request #5080
d294a577 daemon: extend 'print_pl' command, optional filter by type and limit (xiphon)
Diffstat (limited to 'src/daemon/command_parser_executor.cpp')
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 37cb55ec8..73f33a674 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -48,9 +48,34 @@ t_command_parser_executor::t_command_parser_executor( bool t_command_parser_executor::print_peer_list(const std::vector<std::string>& args) { - if (!args.empty()) return false; + if (args.size() > 3) + { + std::cout << "use: print_pl [white] [gray] [<limit>]" << std::endl; + return true; + } + + bool white = false; + bool gray = false; + size_t limit = 0; + for (size_t i = 0; i < args.size(); ++i) + { + if (args[i] == "white") + { + white = true; + } + else if (args[i] == "gray") + { + gray = true; + } + else if (!epee::string_tools::get_xtype_from_string(limit, args[i])) + { + std::cout << "unexpected argument: " << args[i] << std::endl; + return true; + } + } - return m_executor.print_peer_list(); + const bool print_both = !white && !gray; + return m_executor.print_peer_list(white | print_both, gray | print_both, limit); } bool t_command_parser_executor::print_peer_list_stats(const std::vector<std::string>& args) |