-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfooter.go
47 lines (34 loc) · 1.02 KB
/
footer.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
package tcl
import (
"fmt"
"strings"
"time"
"github.com/fatih/color"
"golang.org/x/crypto/ssh/terminal"
)
// Footer prints a simple dashed line.
// It can be used at the end of your output
// to separate it from the following one.
func Footer() {
footerColor := color.New(color.Faint)
width, _, _ := terminal.GetSize(0)
NewLines(1)
footerColor.Print(strings.Repeat(" — ", width/3))
NewLines(2)
}
// FooterC does alsmost the same as the Footer() function, but
// adds a copyright notice with the provided name and the
// current year in the center of the dashed line.
func FooterC(name string) {
footerColor := color.New(color.Faint)
copyColor := color.New(color.Faint, color.Bold)
width, _, _ := terminal.GetSize(0)
year := time.Now().Year()
copyString := fmt.Sprintf(" [ © %d %s ] ", year, name)
leftRight := (width - len(copyString)) / 2
NewLines(1)
footerColor.Print(strings.Repeat(" — ", leftRight/3))
copyColor.Print(copyString)
footerColor.Print(strings.Repeat(" — ", leftRight/3))
NewLines(2)
}