From 0933f339964a3bf2d878db51ac4c6119a5046c8b Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Thu, 6 Jul 2017 08:33:19 -0400 Subject: [PATCH] output flags once When asking for help on more than one item, e.g. foo -h me -h oh -h my just print Flags: once. TBR=scroggo@google.com Change-Id: I67080c7390e6bacf4c36096304dd959229fdd07b Reviewed-on: https://skia-review.googlesource.com/21660 Reviewed-by: Cary Clark Commit-Queue: Cary Clark --- tools/flags/SkCommandLineFlags.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp index bbbc397c2b..bfc9f5eebc 100644 --- a/tools/flags/SkCommandLineFlags.cpp +++ b/tools/flags/SkCommandLineFlags.cpp @@ -233,6 +233,7 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { gOnce = true; bool helpPrinted = false; + bool flagsPrinted = false; // Loop over argv, starting with 1, since the first is just the name of the program. for (int i = 1; i < argc; i++) { if (0 == strcmp("-h", argv[i]) || 0 == strcmp("--help", argv[i])) { @@ -248,8 +249,10 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { // Only print general help message if help for specific flags is not requested. SkDebugf("%s\n%s\n", argv[0], gUsage.c_str()); } - SkDebugf("Flags:\n"); - + if (!flagsPrinted) { + SkDebugf("Flags:\n"); + flagsPrinted = true; + } if (0 == helpFlags.count()) { // If no flags followed --help, print them all SkTDArray allFlags;