this function tries to find the max width of the names column so say we have the following rows for help foo1, foo2, foo3 some string here bar1, b2 some other string here We want to offset the 2nd row usage by some amount so that everything is aligned foo1, foo2, foo3 some string here bar1,
(cmds []*Command, fixed int)
| 604 | // to find that offset we find the length of all the rows and use the max |
| 605 | // to calculate the offset |
| 606 | func offsetCommands(cmds []*Command, fixed int) int { |
| 607 | max := 0 |
| 608 | for _, cmd := range cmds { |
| 609 | s := strings.Join(cmd.Names(), ", ") |
| 610 | if len(s) > max { |
| 611 | max = len(s) |
| 612 | } |
| 613 | } |
| 614 | return max + fixed |
| 615 | } |