From 30a484cbe2f6eb6a36421a0dcb6e19e221522878 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Sat, 17 Oct 2015 23:51:14 -0400
Subject: [PATCH] dhtnode: move help to it's own function

---
 tools/dhtnode.cpp | 42 +++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/tools/dhtnode.cpp b/tools/dhtnode.cpp
index fd377fe4..f4c3f255 100644
--- a/tools/dhtnode.cpp
+++ b/tools/dhtnode.cpp
@@ -56,6 +56,28 @@ void print_node_info(const DhtRunner& dht, const dht_params& params) {
         std::cout << "Public key ID " << dht.getId() << std::endl;
 }
 
+void print_help() {
+    std::cout << "OpenDht command line interface (CLI)" << std::endl;
+    std::cout << "Possible commands:" << std::endl
+              << "  h, help    Print this help message." << std::endl
+              << "  q, quit    Quit the program." << std::endl
+              << "  log        Print the full DHT log." << std::endl;
+
+    std::cout << std::endl << "Node information:" << std::endl
+              << "  ll         Print basic information and stats about the current node." << std::endl
+              << "  ls         Print basic information about current searches." << std::endl
+              << "  ld         Print basic information about currenty stored values on this node." << std::endl
+              << "  lr         Print the full current routing table of this node" << std::endl;
+
+    std::cout << std::endl << "Operations on the DHT:" << std::endl
+              << "  g [key]               Get values at [key]." << std::endl
+              << "  l [key]               Listen for value changes at [key]." << std::endl
+              << "  p [key] [str]         Put string value at [key]." << std::endl
+              << "  s [key] [str]         Put string value at [key], signed with our generated private key." << std::endl
+              << "  e [key] [dest] [str]  Put string value at [key], encrypted for [dest] with its public key (if found)." << std::endl
+              << std::endl;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -103,25 +125,7 @@ main(int argc, char **argv)
             if (std::cin.eof() || op == "x" || op == "q" || op == "exit" || op == "quit") {
                 break;
             } else if (op == "h" || op == "help") {
-                std::cout << "OpenDht command line interface (CLI)" << std::endl;
-                std::cout << "Possible commands:" << std::endl;
-                std::cout << "  h, help    Print this help message." << std::endl;
-                std::cout << "  q, quit    Quit the program." << std::endl;
-                std::cout << "  log        Print the full DHT log." << std::endl;
-
-                std::cout << std::endl << "Node information:" << std::endl;
-                std::cout << "  ll         Print basic information and stats about the current node." << std::endl;
-                std::cout << "  ls         Print basic information about current searches." << std::endl;
-                std::cout << "  ld         Print basic information about currenty stored values on this node." << std::endl;
-                std::cout << "  lr         Print the full current routing table of this node" << std::endl;
-
-                std::cout << std::endl << "Operations on the DHT:" << std::endl;
-                std::cout << "  g [key]               Get values at [key]." << std::endl;
-                std::cout << "  l [key]               Listen for value changes at [key]." << std::endl;
-                std::cout << "  p [key] [str]         Put string value at [key]." << std::endl;
-                std::cout << "  s [key] [str]         Put string value at [key], signed with our generated private key." << std::endl;
-                std::cout << "  e [key] [dest] [str]  Put string value at [key], encrypted for [dest] with its public key (if found)." << std::endl;
-                std::cout << std::endl;
+                print_help();
                 continue;
             } else if (op == "ll") {
                 print_node_info(dht, params);
-- 
GitLab