From ade65f2c2b1cda5490252101bce96a9835882fb1 Mon Sep 17 00:00:00 2001 From: "Vladimir N. Korotenko" Date: Tue, 11 Nov 2025 17:58:02 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=82=20?= =?UTF-8?q?=D1=87=D0=B8=D1=82=D0=B0=D0=B5=D0=BC=D1=8B=D1=85=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BE=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dm-cli/AccountStatus.cpp | 14 +++++--------- dm-cli/AccountUpdate.cpp | 3 +++ dm-cli/Deals.cpp | 1 + dm-cli/Replace.cpp | 9 ++++++++- dm-cli/cleanHtml.cpp | 8 ++++---- dm-cli/common.hpp | 2 ++ dm-cli/main_help_en.txt | 2 +- dm-cli/main_help_ru.txt | 2 +- 8 files changed, 25 insertions(+), 16 deletions(-) diff --git a/dm-cli/AccountStatus.cpp b/dm-cli/AccountStatus.cpp index b712910..efef8a8 100644 --- a/dm-cli/AccountStatus.cpp +++ b/dm-cli/AccountStatus.cpp @@ -33,6 +33,7 @@ int AccountStatus(const std::string address, const char* bkaddress, bool isDebug string url("curl -s "); url += address + "/api/v1/account/status?address=" + bkaddress ; string result = ExecCommand(url.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); string payload(""); @@ -63,6 +64,7 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug) url.append("/api/v1/user/profile"); string result = ExecCommand(url.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); @@ -121,6 +123,7 @@ int AccountRaiting(const std::string address, const char* bkaddress, bool isDebu url.append("/api/v1/user/profile"); string result = ExecCommand(url.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); @@ -174,6 +177,7 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe url.append("/api/v1/deal/feedback/list"); string result = ExecCommand(url.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); std::ostringstream stream; @@ -209,15 +213,7 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe stream << " date: " << val["date"] << endl; stream << " statustext: " << val["statustext"] << endl; stream << " comments: " << val["comments"] << endl; - } - - /* - - deal: ff5f337f-e0ab-4515-857f-3a0c8530dcd3 - date: '2025-10-05T15:29:23' - statustext: positive - comments: positive comment about the deal - - */ + } } stream << "------------Summary--------------" << endl; stream << "total: " << size << endl; diff --git a/dm-cli/AccountUpdate.cpp b/dm-cli/AccountUpdate.cpp index ecc7292..f6f7b22 100644 --- a/dm-cli/AccountUpdate.cpp +++ b/dm-cli/AccountUpdate.cpp @@ -78,6 +78,7 @@ int AccountUpdate::ProcessUrl(std::string date, std::string signature, std::stri data = Replace(data, string("{{URLS}}"), urlout); string result = ExecCommand(data.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); std::ostringstream stream; @@ -106,6 +107,7 @@ int AccountUpdate::ProcessPgp(std::string date, std::string signature, std::stri data = Replace(data, string("{{PGP}}"), pgp); string result = ExecCommand(data.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); std::ostringstream stream; @@ -134,6 +136,7 @@ int AccountUpdate::ProcessBitmessage(std::string date, std::string signature, st data = Replace(data, string("{{BTM}}"), btmsg); string result = ExecCommand(data.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); std::ostringstream stream; diff --git a/dm-cli/Deals.cpp b/dm-cli/Deals.cpp index ca82f97..dc0c8bc 100644 --- a/dm-cli/Deals.cpp +++ b/dm-cli/Deals.cpp @@ -195,6 +195,7 @@ int Deals::Create() { string result = ExecCommand(data.c_str()); + if (result.length() == 0) return NoResponse(""); nlohmann::json jsonData = nlohmann::json::parse(result); std::ostringstream stream; diff --git a/dm-cli/Replace.cpp b/dm-cli/Replace.cpp index 3b92fe4..8128ff6 100644 --- a/dm-cli/Replace.cpp +++ b/dm-cli/Replace.cpp @@ -1,5 +1,6 @@ #include #include "common.hpp" +#include std::string Replace(std::string source, std::string from, std::string out) { std::string res(""); size_t start = 0, stop = 0; @@ -7,4 +8,10 @@ std::string Replace(std::string source, std::string from, std::string out) { stop = from.length(); if (start >= 0 ) res = source.replace(start, stop, out); return res; -} \ No newline at end of file +} + +int NoResponse(std::string mgs) +{ + std::cout << "No response from the server." + mgs << std::endl; + return 1; +} diff --git a/dm-cli/cleanHtml.cpp b/dm-cli/cleanHtml.cpp index 8014d6a..2b3a668 100644 --- a/dm-cli/cleanHtml.cpp +++ b/dm-cli/cleanHtml.cpp @@ -3,17 +3,17 @@ std::string cleanup_html(std::string const &encoded_string) { - size_t start = encoded_string.find("
") + 5;
-	size_t last = encoded_string.find("
"); + int start = encoded_string.find("
") + 5;
+	int last = encoded_string.find("
"); std::string ret; ret = encoded_string.substr(start, last - start); size_t b = 0; - for (size_t a = b; a < ret.length(); a++) + for (int a = b; a < ret.length(); a++) { if (ret[a] == '<') { - for (size_t b = a; b < ret.length(); b++) + for (int b = a; b < ret.length(); b++) { if (ret[b] == '>') { diff --git a/dm-cli/common.hpp b/dm-cli/common.hpp index 70ff1e5..c4e95d9 100644 --- a/dm-cli/common.hpp +++ b/dm-cli/common.hpp @@ -55,4 +55,6 @@ std::string ReadFile(const char *filename); /// @breef Replace in string std::string Replace(std::string source, std::string from, std::string out); +int NoResponse(std::string mgs); + #endif diff --git a/dm-cli/main_help_en.txt b/dm-cli/main_help_en.txt index 33e00ff..86ecf39 100644 --- a/dm-cli/main_help_en.txt +++ b/dm-cli/main_help_en.txt @@ -2,7 +2,7 @@ Usage: dm-cli [global] [] Global options: --debug print debug information, input and output API requests - --address address of the bitdeals dm, default: 127.0.0.1:4999 + --address address of the bitdeals dm, default: https://127.0.0.1:4999 --help print condensed help for all subcommands --version print version string diff --git a/dm-cli/main_help_ru.txt b/dm-cli/main_help_ru.txt index 8eebbea..1588758 100644 --- a/dm-cli/main_help_ru.txt +++ b/dm-cli/main_help_ru.txt @@ -2,7 +2,7 @@ Глобальные параметры: --debug выводить отладочную информацию, входные и выходные API-запросы - --address адрес модуля сделок (dm), по умолчанию: 127.0.0.1:4999 + --address адрес модуля сделок (dm), по умолчанию: https://127.0.0.1:4999 --help вывести краткую справку по всем подкомандам --version вывести строку версии