diff options
author | 2017-05-08 22:10:30 -0400 | |
---|---|---|
committer | 2017-05-09 10:54:05 -0400 | |
commit | ea71d6dc3d60c4ac937f3236c50b20f2daeefd58 (patch) | |
tree | 7e2557b0e9bfee9df8e65e9af5e083f0d6cd0056 | |
parent | 4e0a5cb6209952ff9d83b9aa41d68c133ea4a964 (diff) |
Fix printing of options categories in CLI help
Before it was omitting category titles / section breaks if the first option of the new category happened to be undocumented.
RELNOTES: None
PiperOrigin-RevId: 155458981
-rw-r--r-- | src/main/java/com/google/devtools/common/options/OptionsParser.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/common/options/OptionsParser.java b/src/main/java/com/google/devtools/common/options/OptionsParser.java index c6bd0022a2..728c49070e 100644 --- a/src/main/java/com/google/devtools/common/options/OptionsParser.java +++ b/src/main/java/com/google/devtools/common/options/OptionsParser.java @@ -553,15 +553,14 @@ public class OptionsParser implements OptionsProvider { for (Field optionField : allFields) { Option option = optionField.getAnnotation(Option.class); String category = option.category(); - if (!category.equals(prevCategory)) { - prevCategory = category; + if (!category.equals(prevCategory) + && option.optionUsageRestrictions() == OptionUsageRestrictions.DOCUMENTED) { String description = categoryDescriptions.get(category); if (description == null) { description = "Options category '" + category + "'"; } - if (option.optionUsageRestrictions() == OptionUsageRestrictions.DOCUMENTED) { - desc.append("\n").append(description).append(":\n"); - } + desc.append("\n").append(description).append(":\n"); + prevCategory = category; } if (option.optionUsageRestrictions() == OptionUsageRestrictions.DOCUMENTED) { |