Index: tools/flags/SkCommandLineFlags.cpp |
diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp |
index cddf9fb0b35cc5907f55740391f32bf774cab561..9b2c9616cbf4ebc0a70c4bfc33cc98910053bc4d 100644 |
--- a/tools/flags/SkCommandLineFlags.cpp |
+++ b/tools/flags/SkCommandLineFlags.cpp |
@@ -22,10 +22,8 @@ |
bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, |
SkCommandLineFlags::StringArray* pStrings, |
- const char* defaultValue, const char* helpString, |
- const char* extendedHelpString) { |
- SkFlagInfo* info = new SkFlagInfo(name, shortName, kString_FlagType, helpString, |
- extendedHelpString); |
+ const char* defaultValue, const char* helpString) { |
+ SkFlagInfo* info = new SkFlagInfo(name, shortName, kString_FlagType, helpString); |
info->fDefaultString.set(defaultValue); |
info->fStrings = pStrings; |
@@ -153,16 +151,29 @@ |
// Maximum line length for the help message. |
#define LINE_LENGTH 72 |
-static void print_indented(const SkString& text) { |
- size_t length = text.size(); |
- const char* currLine = text.c_str(); |
+static void print_help_for_flag(const SkFlagInfo* flag) { |
+ SkDebugf(" --%s", flag->name().c_str()); |
+ const SkString& shortName = flag->shortName(); |
+ if (shortName.size() > 0) { |
+ SkDebugf(" or -%s", shortName.c_str()); |
+ } |
+ SkDebugf(":\ttype: %s", flag->typeAsString().c_str()); |
+ if (flag->defaultValue().size() > 0) { |
+ SkDebugf("\tdefault: %s", flag->defaultValue().c_str()); |
+ } |
+ SkDebugf("\n"); |
+ const SkString& help = flag->help(); |
+ size_t length = help.size(); |
+ const char* currLine = help.c_str(); |
const char* stop = currLine + length; |
while (currLine < stop) { |
+ if (strlen(currLine) < LINE_LENGTH) { |
+ // Only one line length's worth of text left. |
+ SkDebugf(" %s\n", currLine); |
+ break; |
+ } |
int lineBreak = SkStrFind(currLine, "\n"); |
- if (lineBreak < 0) { |
- lineBreak = static_cast<int>(strlen(currLine)); |
- } |
- if (lineBreak > LINE_LENGTH) { |
+ if (lineBreak < 0 || lineBreak > LINE_LENGTH) { |
// No line break within line length. Will need to insert one. |
// Find a space before the line break. |
int spaceIndex = LINE_LENGTH - 1; |
@@ -187,26 +198,6 @@ |
currLine += lineBreak; |
} |
} |
-} |
- |
-static void print_help_for_flag(const SkFlagInfo* flag) { |
- SkDebugf(" --%s", flag->name().c_str()); |
- const SkString& shortName = flag->shortName(); |
- if (shortName.size() > 0) { |
- SkDebugf(" or -%s", shortName.c_str()); |
- } |
- SkDebugf(":\ttype: %s", flag->typeAsString().c_str()); |
- if (flag->defaultValue().size() > 0) { |
- SkDebugf("\tdefault: %s", flag->defaultValue().c_str()); |
- } |
- SkDebugf("\n"); |
- const SkString& help = flag->help(); |
- print_indented(help); |
- SkDebugf("\n"); |
-} |
-static void print_extended_help_for_flag(const SkFlagInfo* flag) { |
- print_help_for_flag(flag); |
- print_indented(flag->extendedHelp()); |
SkDebugf("\n"); |
} |
@@ -257,10 +248,6 @@ |
CompareFlagsByName()); |
for (int i = 0; i < allFlags.count(); ++i) { |
print_help_for_flag(allFlags[i]); |
- if (allFlags[i]->extendedHelp().size() > 0) { |
- SkDebugf(" Use '--help %s' for more information.\n", |
- allFlags[i]->name().c_str()); |
- } |
} |
} else { |
for (SkFlagInfo* flag = SkCommandLineFlags::gHead; flag; |
@@ -268,7 +255,7 @@ |
for (int k = 0; k < helpFlags.count(); k++) { |
if (flag->name().equals(helpFlags[k]) || |
flag->shortName().equals(helpFlags[k])) { |
- print_extended_help_for_flag(flag); |
+ print_help_for_flag(flag); |
helpFlags.remove(k); |
break; |
} |