-
Notifications
You must be signed in to change notification settings - Fork 2
/
print.go
55 lines (46 loc) · 1.13 KB
/
print.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
50
51
52
53
54
55
package main
import (
"fmt"
"github.com/fatih/color"
)
var (
defaultMessage = color.New(color.FgWhite, color.Bold)
globalTitleMessage = color.New(color.FgYellow, color.Bold)
titleMessage = color.New(color.FgBlue, color.Bold)
okMessage = color.New(color.FgGreen)
errMessage = color.New(color.FgRed)
)
func printList(le []ListEntry) {
By(Prop("Name", true)).Sort(le)
defaultMessage.Printf("List:\n")
for _, x := range le {
str := fmt.Sprintf(" -> %s@%s:%s\n", x.User, x.Hostname, x.Port)
titleMessage.Printf(" %s", x.Name)
fmt.Printf(str)
for a, c := range x.AnotherOptions {
if a == 0 {
fmt.Printf(" [options]")
fmt.Printf(" %s\n", c)
} else {
fmt.Printf(" %s\n", c)
}
}
}
return
}
func printGeneral(general map[string]string) {
globalTitleMessage.Println(" (*) General Options")
for i, g := range general {
fmt.Printf(" %s: %s\n", i, g)
}
}
func printOK(msg string) {
okMessage.Printf("✔ OK: ")
defaultMessage.Printf("%s\n", msg)
}
func printErr(err error) {
if err != nil {
errMessage.Printf("✗ ERROR: ")
defaultMessage.Printf("%s\n", err.Error())
}
}