-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoyam.go
38 lines (33 loc) · 912 Bytes
/
goyam.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
package main
import (
"fmt"
"os"
"strconv"
. "git.3lab.re/marahin/goyam/goyam"
)
func main() {
firstFile, err := LoadYAMLFile(os.Args[1:][0])
if err != nil {
fmt.Println("Error loading first file...")
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
secondFile, err := LoadYAMLFile(os.Args[1:][1])
summary := YAMLCompare(firstFile, secondFile, "root >")
if summary.ErrorsCount() == 0 && summary.WarningsCount() == 0 {
fmt.Printf(Green("No differences found!\n"))
os.Exit(0)
} else {
for id, err := range summary.Errors {
fmt.Printf("%s %s\n", Red("(error "+strconv.Itoa(id)+")"), err)
}
for id, warn := range summary.Warnings {
fmt.Printf("%s %s\n", Yellow("(warning "+strconv.Itoa(id)+")"), warn)
}
fmt.Printf("%s errors, %s warnings found.\n",
Red(strconv.Itoa(summary.ErrorsCount())),
Yellow(strconv.Itoa(summary.WarningsCount())),
)
os.Exit(1)
}
}