-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathout.go
67 lines (56 loc) · 1.26 KB
/
out.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
56
57
58
59
60
61
62
63
64
65
66
67
package main
func hyphen(uuid string) string {
if len(uuid) != 32 {
return ""
}
return uuid[:8] + "-" + uuid[8:12] + "-" + uuid[12:16] + "-" + uuid[16:20] + "-" + uuid[20:]
}
// │ ┌ ┐ └ ┘ ─ ┤ ├
func printInfo(profile *Profile) {
uuid := hyphen(profile.UUID)
m := map[string]string{
"Username": profile.Name,
"UUID": uuid,
"NameMC": "https://namemc.com/profile/" + profile.Name,
"Laby": "https://laby.net/@" + profile.Name,
"Skin": "https://minotar.net/skin/" + profile.Name,
"Head": "https://crafatar.com/avatars/" + profile.UUID,
}
prettyPrint(m)
}
func line(n int) string {
var s string
for i := 0; i < n; i++ {
s += "─"
}
return s
}
const padding = 1
func prettyPrint(m map[string]string) {
longestK := 0
for k := range m {
if len(k) > longestK {
longestK = len(k)
}
}
longestV := 0
for _, v := range m {
if len(v) > longestV {
longestV = len(v)
}
}
println("┌" + line(longestK+longestV+padding*2+1) + "┐")
for k, v := range m {
print("│ ", k)
padDiff(k, longestK+padding)
print(v)
padDiff(v, longestV+padding)
println("│")
}
println("└" + line(longestK+longestV+padding*2+1) + "┘")
}
func padDiff(s string, n int) {
for i := 0; i < n-len(s); i++ {
print(" ")
}
}