Skip to content

Commit 70db9c9

Browse files
committed
fixup! Update golden files
1 parent 9052c01 commit 70db9c9

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

cli/usage.go

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,30 +164,34 @@ func categorizeFlags(usageOutput string) string {
164164
var prevBody string
165165

166166
for _, cat := range flagCategories {
167-
if buf, ok := categories[cat.name]; ok {
168-
// If the last line of the previous category is a single-line flag,
169-
// then it isn't indented, and an additional newline is necessary to
170-
// make the output readable.
171-
if prevBody != "" {
172-
prevBodyLines := strings.Split(strings.TrimSpace(prevBody), "\n")
173-
if len(prevBodyLines) > 0 {
174-
lastLine := prevBodyLines[len(prevBodyLines)-1]
175-
if strings.HasPrefix(strings.TrimSpace(lastLine), "-") {
176-
_, _ = out.WriteString("\n")
177-
}
167+
buf, ok := categories[cat.name]
168+
if !ok {
169+
continue
170+
}
171+
172+
// If the last line of the previous category is a single-line flag,
173+
// then it isn't indented, and an additional newline is necessary to
174+
// make the output readable.
175+
if prevBody != "" {
176+
prevBodyLines := strings.Split(strings.TrimSpace(prevBody), "\n")
177+
if len(prevBodyLines) > 0 {
178+
lastLine := prevBodyLines[len(prevBodyLines)-1]
179+
if strings.HasPrefix(strings.TrimSpace(lastLine), "-") {
180+
_, _ = out.WriteString("\n")
178181
}
179182
}
183+
}
180184

181-
if len(categories) == 1 {
182-
// Don't bother qualifying list if there's only one category.
183-
_, _ = fmt.Fprintf(&out, "%s\n", usageHeader("Flags:"))
184-
} else {
185-
_, _ = fmt.Fprintf(&out, "%s\n", usageHeader(cat.name+" Flags:"))
186-
}
187-
body := buf.String()
188-
_, _ = out.WriteString(body)
189-
prevBody = body
185+
if len(categories) == 1 {
186+
// Don't bother qualifying list name if there's only one category.
187+
_, _ = fmt.Fprintf(&out, "%s\n", usageHeader("Flags:"))
188+
} else {
189+
_, _ = fmt.Fprintf(&out, "%s\n", usageHeader(cat.name+" Flags:"))
190190
}
191+
192+
body := buf.String()
193+
_, _ = out.WriteString(body)
194+
prevBody = body
191195
}
192196

193197
return out.String()

0 commit comments

Comments
 (0)