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 <caryclark@skia.org> Commit-Queue: Cary Clark <caryclark@skia.org>
This commit is contained in:
parent
bdf6c62a19
commit
0933f33996
@ -233,6 +233,7 @@ void SkCommandLineFlags::Parse(int argc, char** argv) {
|
|||||||
gOnce = true;
|
gOnce = true;
|
||||||
|
|
||||||
bool helpPrinted = false;
|
bool helpPrinted = false;
|
||||||
|
bool flagsPrinted = false;
|
||||||
// Loop over argv, starting with 1, since the first is just the name of the program.
|
// Loop over argv, starting with 1, since the first is just the name of the program.
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (0 == strcmp("-h", argv[i]) || 0 == strcmp("--help", argv[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.
|
// Only print general help message if help for specific flags is not requested.
|
||||||
SkDebugf("%s\n%s\n", argv[0], gUsage.c_str());
|
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 (0 == helpFlags.count()) {
|
||||||
// If no flags followed --help, print them all
|
// If no flags followed --help, print them all
|
||||||
SkTDArray<SkFlagInfo*> allFlags;
|
SkTDArray<SkFlagInfo*> allFlags;
|
||||||
|
Loading…
Reference in New Issue
Block a user