Add usage message to event_log_visualizer.

Bug: webrtc:10616
Change-Id: I1623175abc7e60c1a3cf29e3d99fdde0e4140b1f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/146208
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28663}
This commit is contained in:
Mirko Bonadei 2019-07-24 15:29:47 +02:00 committed by Commit Bot
parent aa59eca891
commit f2d97b8d58
2 changed files with 50 additions and 40 deletions

View File

@ -337,8 +337,11 @@ if (rtc_include_tests) {
"../test:fileutils", "../test:fileutils",
"../test:test_support", "../test:test_support",
"//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/flags:config",
"//third_party/abseil-cpp/absl/flags:flag", "//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/flags:parse", "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/flags:usage",
"//third_party/abseil-cpp/absl/strings",
] ]
} }
} }

View File

@ -21,6 +21,9 @@
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/flags/flag.h" #include "absl/flags/flag.h"
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "absl/flags/usage.h"
#include "absl/flags/usage_config.h"
#include "absl/strings/match.h"
#include "logging/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/rtc_event_log.h"
#include "logging/rtc_event_log/rtc_event_log_parser.h" #include "logging/rtc_event_log/rtc_event_log_parser.h"
#include "modules/audio_coding/neteq/include/neteq.h" #include "modules/audio_coding/neteq/include/neteq.h"
@ -37,7 +40,8 @@
ABSL_FLAG(std::string, ABSL_FLAG(std::string,
plot, plot,
"default", "default",
"A comma separated list of plot names. See below for valid options."); "A comma separated list of plot names. See --list_plots for valid "
"options.");
ABSL_FLAG( ABSL_FLAG(
std::string, std::string,
@ -92,6 +96,11 @@ ABSL_FLAG(bool,
false, false,
"Output charts as protobuf instead of python code."); "Output charts as protobuf instead of python code.");
ABSL_FLAG(bool,
list_plots,
false,
"List of registered plots (for use with the --plot flag)");
using webrtc::Plot; using webrtc::Plot;
namespace { namespace {
@ -172,25 +181,23 @@ class PlotMap {
std::vector<PlotDeclaration> plots_; std::vector<PlotDeclaration> plots_;
}; };
bool ContainsHelppackageFlags(absl::string_view filename) {
return absl::EndsWith(filename, "main.cc");
}
} // namespace } // namespace
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
std::string program_name = argv[0]; absl::SetProgramUsageMessage(
std::string usage =
"A tool for visualizing WebRTC event logs.\n" "A tool for visualizing WebRTC event logs.\n"
"Example usage:\n" + "Example usage:\n"
program_name + " <logfile> | python\n" + "Run " + program_name + "./event_log_visualizer <logfile> | python\n");
" --help for a list of command line options\n"; absl::FlagsUsageConfig config;
config.contains_help_flags = &ContainsHelppackageFlags;
absl::SetFlagsUsageConfig(config);
std::vector<char*> args = absl::ParseCommandLine(argc, argv); std::vector<char*> args = absl::ParseCommandLine(argc, argv);
// TODO(bugs.webrtc.org/10616): Add program usage message when Abseil
// flags supports it.
if (args.size() != 2) {
std::cerr << "TODO(bugs.webrtc.org/10616): Print flag list again when "
"Abseil supports it.\n";
}
// Flag replacements // Flag replacements
std::map<std::string, std::vector<std::string>> flag_aliases = { std::map<std::string, std::vector<std::string>> flag_aliases = {
{"default", {"default",
@ -529,32 +536,32 @@ int main(int argc, char* argv[]) {
} }
} }
// if (argc != 2) { if (absl::GetFlag(FLAGS_list_plots)) {
// // Print usage information. std::cerr << "List of registered plots (for use with the --plot flag):"
// std::cerr << usage; << std::endl;
// if (FLAG_help) { for (const auto& plot : plots) {
// rtc::FlagList::Print(nullptr, false); // TODO(terelius): Also print a help text.
// std::cerr << "List of registered plots (for use with the --plot flag):" std::cerr << " " << plot.label << std::endl;
// << std::endl; }
// for (const auto& plot : plots) { // The following flag doesn't fit the model used for the other plots.
// // TODO(terelius): Also print a help text. std::cerr << "simulated_neteq_jitter_buffer_delay" << std::endl;
// std::cerr << " " << plot.label << std::endl; std::cerr << "List of plot aliases (for use with the --plot flag):"
// } << std::endl;
// // The following flag doesn't fit the model used for the other plots. std::cerr << " all = every registered plot" << std::endl;
// std::cerr << "simulated_neteq_jitter_buffer_delay" << std::endl; for (const auto& alias : flag_aliases) {
// std::cerr << "List of plot aliases (for use with the --plot flag):" std::cerr << " " << alias.first << " = ";
// << std::endl; for (const auto& replacement : alias.second) {
// std::cerr << " all = every registered plot" << std::endl; std::cerr << replacement << ",";
// for (const auto& alias : flag_aliases) { }
// std::cerr << " " << alias.first << " = "; std::cerr << std::endl;
// for (const auto& replacement : alias.second) { }
// std::cerr << replacement << ","; return 0;
// } }
// std::cerr << std::endl; if (args.size() != 2) {
// } // Print usage information.
// } std::cerr << absl::ProgramUsageMessage();
// return 0; return 1;
// } }
for (const auto& plot : plots) { for (const auto& plot : plots) {
if (plot.enabled) { if (plot.enabled) {