From ffa70f992d5b84028c0ed4702f24914a779d7107 Mon Sep 17 00:00:00 2001
From: Dmtiriy Gerasimov <naeper@demlabs.net>
Date: Tue, 7 May 2019 15:44:11 +0700
Subject: [PATCH] [*] Updated internal node cmd subsystem

---
 dap_chain_node_cli.c     | 12 +++++++++---
 dap_chain_node_cli_cmd.c |  9 +++------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/dap_chain_node_cli.c b/dap_chain_node_cli.c
index 12eae20c70..36c6f46e35 100755
--- a/dap_chain_node_cli.c
+++ b/dap_chain_node_cli.c
@@ -298,7 +298,7 @@ static void* thread_one_client_func(void *args)
                     str_reply = dap_strdup_printf("can't recognize command=%s", str_cmd);
                     log_it(L_ERROR, str_reply);
                 }
-                char *reply_body = dap_strdup_printf("%d\r\n%s\r\n", res, (str_reply) ? str_reply : "");
+                char *reply_body = dap_strdup_printf("ret_code: %d\r\n%s\r\n", res, (str_reply) ? str_reply : "");
                 // return the result of the command function
                 char *reply_str = dap_strdup_printf("HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s",
                         strlen(reply_body), reply_body);
@@ -472,8 +472,14 @@ int dap_chain_node_cli_init(dap_config_t * g_config)
             "traceroute host\n");
     dap_chain_node_cli_cmd_item_create ("tracepath", com_tracepath, "Traces path to a network host along this path",
             "tracepath host\n");
-    dap_chain_node_cli_cmd_item_create ("help", com_help, "Description of command parameters\n", "");
-    dap_chain_node_cli_cmd_item_create ("?", com_help, "Synonym for 'help'\n", "");
+    dap_chain_node_cli_cmd_item_create ("help", com_help, "Description of command parameters",
+                                        "help [<command>]\n"
+                                        "\tObtain help for <command> or get the total list of the commands\n"
+                                        );
+    dap_chain_node_cli_cmd_item_create ("?", com_help, "Synonym for \"help\"",
+                                        "? [<command>]\n"
+                                        "\tObtain help for <command> or get the total list of the commands\n"
+                                        );
     dap_chain_node_cli_cmd_item_create ("wallet", com_tx_wallet, "Wallet info", "wallet [list | info -addr <addr> -w <wallet_name>]\n");
     dap_chain_node_cli_cmd_item_create ("token_emit", com_token_emit, "Token emission",
             "token_emit addr <addr> tokent <token> certs <cert> emission_value <val>\n");
diff --git a/dap_chain_node_cli_cmd.c b/dap_chain_node_cli_cmd.c
index 47270f0d47..5363263058 100755
--- a/dap_chain_node_cli_cmd.c
+++ b/dap_chain_node_cli_cmd.c
@@ -1272,15 +1272,12 @@ int com_help(int argc, const char ** argv, char **str_reply)
         dap_chain_node_cmd_item_t *l_cmd = dap_chain_node_cli_cmd_get_first();
         dap_string_printf(l_help_list_str,"");
         while (l_cmd ){
-            dap_string_append_printf(l_help_list_str,"\t\t--== %s ==-- \n\n %s \n",
-                                     l_cmd->doc? l_cmd->doc : l_cmd->name,
-                                     l_cmd->doc_ex ? l_cmd->doc_ex : "");
+            dap_string_append_printf(l_help_list_str,"%s:\t\t\t%s\n",
+                                     l_cmd->name, l_cmd->doc? l_cmd->doc: "(undocumented command)");
             l_cmd = (dap_chain_node_cmd_item_t*) l_cmd->hh.next;
         }
         dap_chain_node_cli_set_reply_text(str_reply,
-                                          "help <cmd name>\n"
-                                          "\t<cmd name> Command for help\n"
-                                          "%s\n",l_help_list_str->len? l_help_list_str->str : "");
+                                          "Available commands:\n\n%s\n", l_help_list_str->len? l_help_list_str->str : "NO ANY COMMAND WERE DEFINED");
         return 0;
     }
     return -1;
-- 
GitLab