From d294a577faa11910985920f1e70a39398e53d82d Mon Sep 17 00:00:00 2001 From: xiphon Date: Fri, 18 Jan 2019 00:55:55 +0000 Subject: daemon: extend 'print_pl' command, optional filter by type and limit --- src/daemon/command_parser_executor.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/daemon/command_parser_executor.cpp') diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 853cde9c3..d31a6507e 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& args) { - if (!args.empty()) return false; + if (args.size() > 3) + { + std::cout << "use: print_pl [white] [gray] []" << 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& args) -- cgit v1.2.3