MCPcopy Create free account
hub / github.com/Songmu/make2help / string

Method string

rules.go:20–44  ·  view source on GitHub ↗
(all, colorful bool)

Source from the content-addressed store, hash-verified

18}
19
20func (r rules) string(all, colorful bool) string {
21 var buf bytes.Buffer
22 indent, tasks := r.indentAndRules(all)
23 colorfunc := ansi.ColorFunc("cyan")
24 for _, task := range tasks {
25 helplines := r[task]
26 msg := task
27 if colorful {
28 msg = colorfunc(msg)
29 }
30 buf.WriteString(msg)
31 buf.WriteString(":")
32 restIndent := indent - len(task) - 1
33 if len(helplines) < 1 {
34 buf.WriteString("\n")
35 }
36 for _, helpline := range helplines {
37 buf.WriteString(strings.Repeat(" ", restIndent))
38 buf.WriteString(helpline)
39 buf.WriteString("\n")
40 restIndent = indent
41 }
42 }
43 return buf.String()
44}
45
46func (r rules) indentAndRules(all bool) (int, []string) {
47 indent := 19

Callers 2

TestStringFunction · 0.95
RunMethod · 0.95

Calls 1

indentAndRulesMethod · 0.95

Tested by 1

TestStringFunction · 0.76