tools: use GNU Readline

* live command edition
* history browsing
This commit is contained in:
Adrien Béraud committed 2015-11-04 00:50:12 -05:00
1 parent 64d52f7418
commit 014bf168bb
6 files changed
+85 -13

No files matched your search

+9 -4
View File
@@ -114,16 +114,21 @@ main(int argc, char **argv)
print_node_info(dht, params);
std::cout << " (type 'h' or 'help' for a list of possible commands)" << std::endl << std::endl;
// using the GNU History API
using_history();
while (true)
{
std::cout << ">> ";
std::string line;
std::getline(std::cin, line);
// using the GNU Readline API
std::string line = readLine();
if (!line.empty() && line[0] == '\0')
break;
std::istringstream iss(line);
std::string op, idstr, value;
iss >> op >> idstr;
if (std::cin.eof() || op == "x" || op == "q" || op == "exit" || op == "quit") {
if (op == "x" || op == "q" || op == "exit" || op == "quit") {
break;
} else if (op == "h" || op == "help") {
print_help();