-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorer.go
More file actions
57 lines (42 loc) · 1.08 KB
/
Copy pathcolorer.go
File metadata and controls
57 lines (42 loc) · 1.08 KB
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
package main
import (
"flag"
)
type pkgToBeColored []string
func (c *pkgToBeColored) String() string {
return "Package name to be colored"
}
func (c *pkgToBeColored) Set(value string) error {
*c = append(*c, value)
return nil
}
type pkgColorList []string
func (c *pkgColorList) String() string {
return "Package name to be colored"
}
func (c *pkgColorList) Set(value string) error {
*c = append(*c, value)
return nil
}
var pkgToBeColoredVar pkgToBeColored
var pkgColorListVar pkgColorList
func AddColor(allValues map[string][]string) map[string][]string {
if len(pkgToBeColoredVar) != len(pkgColorListVar) {
panic("Need same size of pkg color and the color? need -cp and -cn")
}
result := allValues
for i, _ := range pkgToBeColoredVar {
p := pkgToBeColoredVar[i]
c := pkgColorListVar[i]
deps, ok := result[p]
if !ok {
panic("Cannot find package " + p)
}
result[p] = append(deps, "| "+c)
}
return result
}
func ColorerInit() {
flag.Var(&pkgToBeColoredVar, "cp", "package name to be colored")
flag.Var(&pkgColorListVar, "cn", "color name to the package")
}