| 18 | } |
| 19 | |
| 20 | func (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 | |
| 46 | func (r rules) indentAndRules(all bool) (int, []string) { |
| 47 | indent := 19 |