Возврат читаемых ошибок.
This commit is contained in:
@@ -33,6 +33,7 @@ int AccountStatus(const std::string address, const char* bkaddress, bool isDebug
|
|||||||
string url("curl -s ");
|
string url("curl -s ");
|
||||||
url += address + "/api/v1/account/status?address=" + bkaddress ;
|
url += address + "/api/v1/account/status?address=" + bkaddress ;
|
||||||
string result = ExecCommand(url.c_str());
|
string result = ExecCommand(url.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
string payload("");
|
string payload("");
|
||||||
@@ -63,6 +64,7 @@ int AccountInfo(const std::string address, const char* bkaddress, bool isDebug)
|
|||||||
url.append("/api/v1/user/profile");
|
url.append("/api/v1/user/profile");
|
||||||
|
|
||||||
string result = ExecCommand(url.c_str());
|
string result = ExecCommand(url.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
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");
|
url.append("/api/v1/user/profile");
|
||||||
|
|
||||||
string result = ExecCommand(url.c_str());
|
string result = ExecCommand(url.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
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");
|
url.append("/api/v1/deal/feedback/list");
|
||||||
|
|
||||||
string result = ExecCommand(url.c_str());
|
string result = ExecCommand(url.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
@@ -210,14 +214,6 @@ int AccountFeedbacks(const std::string address, const char* bkaddress, bool isDe
|
|||||||
stream << " statustext: " << val["statustext"] << endl;
|
stream << " statustext: " << val["statustext"] << endl;
|
||||||
stream << " comments: " << val["comments"] << 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 << "------------Summary--------------" << endl;
|
||||||
stream << "total: " << size << endl;
|
stream << "total: " << size << endl;
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ int AccountUpdate::ProcessUrl(std::string date, std::string signature, std::stri
|
|||||||
data = Replace(data, string("{{URLS}}"), urlout);
|
data = Replace(data, string("{{URLS}}"), urlout);
|
||||||
|
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
@@ -106,6 +107,7 @@ int AccountUpdate::ProcessPgp(std::string date, std::string signature, std::stri
|
|||||||
data = Replace(data, string("{{PGP}}"), pgp);
|
data = Replace(data, string("{{PGP}}"), pgp);
|
||||||
|
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
@@ -134,6 +136,7 @@ int AccountUpdate::ProcessBitmessage(std::string date, std::string signature, st
|
|||||||
data = Replace(data, string("{{BTM}}"), btmsg);
|
data = Replace(data, string("{{BTM}}"), btmsg);
|
||||||
|
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ int Deals::Create() {
|
|||||||
|
|
||||||
|
|
||||||
string result = ExecCommand(data.c_str());
|
string result = ExecCommand(data.c_str());
|
||||||
|
if (result.length() == 0) return NoResponse("");
|
||||||
nlohmann::json jsonData = nlohmann::json::parse(result);
|
nlohmann::json jsonData = nlohmann::json::parse(result);
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include <iostream>
|
||||||
std::string Replace(std::string source, std::string from, std::string out) {
|
std::string Replace(std::string source, std::string from, std::string out) {
|
||||||
std::string res("");
|
std::string res("");
|
||||||
size_t start = 0, stop = 0;
|
size_t start = 0, stop = 0;
|
||||||
@@ -8,3 +9,9 @@ std::string Replace(std::string source, std::string from, std::string out) {
|
|||||||
if (start >= 0 ) res = source.replace(start, stop, out);
|
if (start >= 0 ) res = source.replace(start, stop, out);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NoResponse(std::string mgs)
|
||||||
|
{
|
||||||
|
std::cout << "No response from the server." + mgs << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
std::string cleanup_html(std::string const &encoded_string)
|
std::string cleanup_html(std::string const &encoded_string)
|
||||||
{
|
{
|
||||||
|
|
||||||
size_t start = encoded_string.find("<pre>") + 5;
|
int start = encoded_string.find("<pre>") + 5;
|
||||||
size_t last = encoded_string.find("</pre>");
|
int last = encoded_string.find("</pre>");
|
||||||
std::string ret;
|
std::string ret;
|
||||||
ret = encoded_string.substr(start, last - start);
|
ret = encoded_string.substr(start, last - start);
|
||||||
|
|
||||||
size_t b = 0;
|
size_t b = 0;
|
||||||
for (size_t a = b; a < ret.length(); a++)
|
for (int a = b; a < ret.length(); a++)
|
||||||
{
|
{
|
||||||
if (ret[a] == '<')
|
if (ret[a] == '<')
|
||||||
{
|
{
|
||||||
for (size_t b = a; b < ret.length(); b++)
|
for (int b = a; b < ret.length(); b++)
|
||||||
{
|
{
|
||||||
if (ret[b] == '>')
|
if (ret[b] == '>')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -55,4 +55,6 @@ std::string ReadFile(const char *filename);
|
|||||||
/// @breef Replace in string
|
/// @breef Replace in string
|
||||||
std::string Replace(std::string source, std::string from, std::string out);
|
std::string Replace(std::string source, std::string from, std::string out);
|
||||||
|
|
||||||
|
int NoResponse(std::string mgs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Usage: dm-cli [global] <group> [<args>]
|
|||||||
|
|
||||||
Global options:
|
Global options:
|
||||||
--debug print debug information, input and output API requests
|
--debug print debug information, input and output API requests
|
||||||
--address <ip:port> address of the bitdeals dm, default: 127.0.0.1:4999
|
--address <ip:port> address of the bitdeals dm, default: https://127.0.0.1:4999
|
||||||
--help print condensed help for all subcommands
|
--help print condensed help for all subcommands
|
||||||
--version print version string
|
--version print version string
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Глобальные параметры:
|
Глобальные параметры:
|
||||||
--debug выводить отладочную информацию, входные и выходные API-запросы
|
--debug выводить отладочную информацию, входные и выходные API-запросы
|
||||||
--address <ip:port> адрес модуля сделок (dm), по умолчанию: 127.0.0.1:4999
|
--address <ip:port> адрес модуля сделок (dm), по умолчанию: https://127.0.0.1:4999
|
||||||
--help вывести краткую справку по всем подкомандам
|
--help вывести краткую справку по всем подкомандам
|
||||||
--version вывести строку версии
|
--version вывести строку версии
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user