-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.go
49 lines (37 loc) · 1.32 KB
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package tcl
import (
"fmt"
"github.com/fatih/color"
)
// ListItemU takes a string and displays it as a unordered list item.
// With the indentation parameter you can specify if and how deep you want to indent the entry, which might be useful is you want to nest entries.
func ListItemU(text string, indentation int) {
itemColor := color.New(color.FgWhite)
indent(indentation)
fmt.Print("• ")
itemColor.Print(text)
NewLines(1)
}
// ListItemO takes a string and displays it as a ordered list item.
// With the indentation parameter you can specify if and how deep you want to indent the entry, which might be useful is you want to nest entries.
// With the number parameter, you can specify the number that is displayed before the entry.
func ListItemO(text string, indentation int, number int) {
numberColor := color.New(color.Faint)
itemColor := color.New(color.FgWhite)
indent(indentation)
numberColor.Printf("%d. ", number)
itemColor.Print(text)
NewLines(1)
}
// ListO creates a ordered list from a provided array of strings.
func ListO(list []string, indentation int) {
for i, item := range list {
ListItemO(item, indentation, i+1)
}
}
// ListU creates a unordered list from a provided array of strings.
func ListU(list []string, indentation int) {
for _, item := range list {
ListItemU(item, indentation)
}
}