-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (53 loc) · 1.26 KB
/
Copy pathmain.go
File metadata and controls
58 lines (53 loc) · 1.26 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
package main
import (
"fmt"
"time"
"zart/api"
"zart/config"
"zart/config/cmd"
"zart/handler"
"github.com/briandowns/spinner"
)
func init() {
cmd.InitLoggerStdout()
cmd.SetupFlags()
if config.UPDATE_SOURCES {
handler.EnviromentSourceUpdates()
}
err := handler.EnviromentValidation()
if err != nil {
cmd.ErrorLogger.Fatalln(err)
}
fmt.Println("All resources found successfully.")
}
func main() {
if config.API {
api.Server()
} else {
s := spinner.New(spinner.CharSets[14], 100*time.Millisecond)
s.Start()
startTime := time.Now()
var hh handler.Normalizer
targets, err := hh.NormalizerAction()
if err != nil {
s.Stop()
cmd.ErrorLogger.Fatalf("error in normalize the data, error : %v\n", err)
}
if config.REPORT {
err := handler.HandleReport(targets, config.REPORT_BASE, s)
if err != nil {
s.Stop()
cmd.ErrorLogger.Fatalf("error in handling report output, error : %v\n", err)
}
} else {
n, err := handler.HandleOutput(targets, s)
if err != nil {
cmd.ErrorLogger.Fatalf("error in handling output, error : %v\n", err)
}
fmt.Printf("count of records : %v\n", n)
}
executionTime := time.Since(startTime)
fmt.Printf("it took %.2f minutes \n", executionTime.Abs().Minutes())
fmt.Println("✅ Done!")
}
}