From ea71d6dc3d60c4ac937f3236c50b20f2daeefd58 Mon Sep 17 00:00:00 2001 From: brandjon Date: Mon, 8 May 2017 22:10:30 -0400 Subject: [PATCH] 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 --- .../google/devtools/common/options/OptionsParser.java | 9 ++++----- 1 file 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 c6bd0022a267c4..728c49070eef70 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 String describeOptions( 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) {