diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d4e413 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +*.d +*.o +src/cli/cli + + # VSCode +.vscode \ No newline at end of file diff --git a/README.md b/README.md index 4fc92f3..f8cdec6 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ The `src` directory contains the source code to the command line version of Bredbandskollen CLI, a bandwidth measurement tool. +# Changes from dotse +- CVS output + + # How to build Bredbandskollen's CLI client On Windows, open diff --git a/src/cli/cliclient.cpp b/src/cli/cliclient.cpp index 054c70a..4515067 100644 --- a/src/cli/cliclient.cpp +++ b/src/cli/cliclient.cpp @@ -32,6 +32,7 @@ CliClient::CliClient(const TaskConfig &config) : #else out_is_tty = isatty(fileno(stdout)); #endif + limiter = the_config.value("limiter"); out_quiet = (the_config.value("quiet") == "1" || the_config.value("logfile") == "-"); if (!the_config.value("out").empty()) { @@ -167,6 +168,7 @@ void CliClient::newEventFromAgent(std::deque &return_msgs, std::string tst = arg_obj["task"].string_value(); if (tst == "global") { if (out_quiet) { + // Enable output: out->clear(std::istream::goodbit); @@ -174,17 +176,17 @@ void CliClient::newEventFromAgent(std::deque &return_msgs, *out << "\n\nRESULT: "; std::string measurement_id = arg_obj["MeasurementID"].string_value(); - *out << measurement_id << ' ' - << report.download << ' ' - << report.upload << ' ' - << report.latency << ' ' - << report.measurement_server << ' ' - << report.isp << ' ' + *out << measurement_id << limiter + << report.download << limiter + << report.upload << limiter + << report.latency << limiter + << report.measurement_server << limiter + << report.isp << limiter << report.ticket; if (report.rating.empty()) *out << std::endl; else - *out << ' ' << report.rating << std::endl; + *out << limiter << report.rating << std::endl; } return_msgs.push_back(BridgeTask::msgToAgent("quit")); } else if (tst == "latency") { diff --git a/src/cli/cliclient.h b/src/cli/cliclient.h index e0bd3ed..6e6cfb9 100644 --- a/src/cli/cliclient.h +++ b/src/cli/cliclient.h @@ -37,6 +37,7 @@ class CliClient : public Logger, public SynchronousClient { void do_output(const char *msg, bool final = false); void do_output(double value, const char *msg, bool final = false); std::ostream *out; + std::string limiter = " "; std::ostringstream current_line; std::string current_header; bool out_is_tty, out_quiet; diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp index 6550f0f..cb624de 100644 --- a/src/cli/utils.cpp +++ b/src/cli/utils.cpp @@ -98,6 +98,9 @@ bool parseArgs(int argc, char *argv[], return false; } else if (arg == "--quiet") { client_cfg.set("quiet", "1"); + } else if (arg == "--csv") { + client_cfg.set("quiet", "1"); + client_cfg.set("limiter", ","); } else if (arg == "--local") { mode = (mode == CliMode::NONE) ? CliMode::LOCAL : CliMode::IN_ERROR; #if defined(RUN_SERVER) @@ -225,6 +228,7 @@ bool parseArgs(int argc, char *argv[], << "\nCommand line interface:\n" << " --quiet Write a single line of output\n" << " --out=FILENAME Append output to FILENAME instead of stdout\n" + << " --csv Write a single line as comma separated\n" #endif << std::endl; return false;