Skip to content

Commit 31141c7

Browse files
Stebalienhannahhoward
authored andcommitted
help: compact flags
Instead of aligning flags in columns, display them right next to each other. Otherwise, they take up *way* too much space.
1 parent fa07c33 commit 31141c7

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

cli/helptext.go

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -317,35 +317,14 @@ func optionText(cmd ...*cmds.Command) []string {
317317
}
318318
}
319319

320-
// add option names to output (with each name aligned)
321-
lines := make([]string, 0)
322-
j := 0
323-
for {
324-
done := true
325-
i := 0
326-
for _, opt := range options {
327-
if len(lines) < i+1 {
328-
lines = append(lines, "")
329-
}
330-
331-
names := sortByLength(opt.Names())
332-
if len(names) >= j+1 {
333-
lines[i] += optionFlag(names[j])
334-
}
335-
if len(names) > j+1 {
336-
lines[i] += ", "
337-
done = false
338-
}
339-
340-
i++
341-
}
342-
343-
if done {
344-
break
320+
// add option names to output
321+
lines := make([]string, len(options))
322+
for i, opt := range options {
323+
flags := sortByLength(opt.Names())
324+
for j, f := range flags {
325+
flags[j] = optionFlag(f)
345326
}
346-
347-
lines = align(lines)
348-
j++
327+
lines[i] = strings.Join(flags, ", ")
349328
}
350329
lines = align(lines)
351330

0 commit comments

Comments
 (0)