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

Function wrap

help.go:538–560  ·  view source on GitHub ↗
(input string, offset int, wrapAt int)

Source from the content-addressed store, hash-verified

536}
537
538func wrap(input string, offset int, wrapAt int) string {
539 var ss []string
540
541 lines := strings.Split(input, "\n")
542
543 padding := strings.Repeat(" ", offset)
544
545 for i, line := range lines {
546 if line == "" {
547 ss = append(ss, line)
548 } else {
549 wrapped := wrapLine(line, offset, wrapAt, padding)
550 if i == 0 {
551 ss = append(ss, wrapped)
552 } else {
553 ss = append(ss, padding+wrapped)
554 }
555
556 }
557 }
558
559 return strings.Join(ss, "\n")
560}
561
562func wrapLine(input string, offset int, wrapAt int, padding string) string {
563 if wrapAt <= offset || len(input) <= wrapAt-offset {

Callers 2

DefaultPrintHelpCustomFunction · 0.85
TestWrapFunction · 0.85

Calls 1

wrapLineFunction · 0.85

Tested by 1

TestWrapFunction · 0.68