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
@@ -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");
- }
+ prevCategory = category;
}
if (option.optionUsageRestrictions() == OptionUsageRestrictions.DOCUMENTED) {
