MCPcopy
hub / github.com/urfave/cli / offsetCommands

Function offsetCommands

help.go:606–615  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

604// to find that offset we find the length of all the rows and use the max
605// to calculate the offset
606func 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}

Callers

nothing calls this directly

Calls 1

NamesMethod · 0.65

Tested by

no test coverage detected