-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
90 lines (75 loc) · 2.35 KB
/
main.go
File metadata and controls
90 lines (75 loc) · 2.35 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"flag"
"fmt"
"github.com/mgutz/ansi"
// "github.com/tubesandlube/bron/filters"
)
var (
blessedPtr string
dashboardPtr string
forcePtr bool
quietPtr bool
repoPtr string
repoPathPtr string
statusPtr bool
verbosePtr bool
vizPtr bool
)
func colorize(msg string) string {
lime := ansi.ColorCode("green+h:black")
reset := ansi.ColorCode("reset")
return (lime + msg + reset)
}
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
flag.StringVar(&blessedPtr, "blessedPath", "/go/src/github.com/yaronn/blessed-contrib", "Path where blessed-contrib is installed")
flag.StringVar(&dashboardPtr, "dashboard", "example", "Name of dashboard to use for visualization")
flag.BoolVar(&quietPtr, "q", false, "Supresses all output, except status")
flag.StringVar(&repoPtr, "repo", "github.com/tubesandlube/bron", "Git repository to scan")
flag.StringVar(&repoPathPtr, "path", "", "Git repository file path to scan (not currently implemented)")
flag.BoolVar(&statusPtr, "s", true, "Outputs status of completion of analysis")
flag.BoolVar(&verbosePtr, "v", false, "verbosity level")
flag.BoolVar(&vizPtr, "viz", false, "Visualize the results, requires blessed")
flag.BoolVar(&forcePtr, "f", false, "Force update the data")
flag.Parse()
if repoPtr == "" && repoPathPtr == "" {
fmt.Println("please specify either a repo or a path to a git repo to scan")
} else if repoPtr != "" && repoPathPtr != "" {
fmt.Println("please specify only either a repo or a path to a git repo to scan, not both")
} else {
if !quietPtr {
if verbosePtr {
fmt.Println("going to scan repository", repoPtr, "...")
}
}
}
flagStrings := []string{blessedPtr, dashboardPtr, repoPtr, repoPathPtr}
flagBools := []bool{quietPtr, statusPtr, verbosePtr, vizPtr, forcePtr}
if repoPtr != "" {
if !forcePtr {
if checkData(flagStrings) {
if !quietPtr {
if verbosePtr {
fmt.Println("found existing data for", repoPtr, "using that ...")
}
if vizPtr {
showDashboard(flagStrings)
}
}
} else {
clonePath := "https://" + repoPtr + ".git"
uuidRepo := cloneRepo(clonePath)
updateDashboardData(uuidRepo, flagStrings, flagBools)
}
} else {
clonePath := "https://" + repoPtr + ".git"
uuidRepo := cloneRepo(clonePath)
updateDashboardData(uuidRepo, flagStrings, flagBools)
}
}
}