This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
89 lines (80 loc) · 2.12 KB
/
main.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"flag"
"fmt"
"log"
"os"
"strings"
"github.com/prytoegrian/check-break/check"
)
func main() {
path := flag.String("p", "", "Path to analyse (optional)")
startingPoint := flag.String("s", "", "Git starting point")
endingPoint := flag.String("e", "", "Git ending point")
configFilename := flag.String("c", "cb-config.json", "Config filename, relative to analysed path (optional)")
flag.Parse()
if *startingPoint == "" {
log.Fatalln("Starting point is missing, use -h for details")
}
if *endingPoint == "" {
log.Fatalln("Ending point is missing, use -h for details")
}
b, errInit := check.Init(workingPath(*path), *startingPoint, *endingPoint, *configFilename)
if errInit != nil {
log.Fatal("Init failed : ", errInit)
}
displayTitle(b)
report, errReport := b.Report()
if errReport != nil {
log.Fatal("Error during report construction : ", errReport)
}
displayBreaks(report)
displayIgnored(report)
displayExclusions(report)
}
func workingPath(userPath string) string {
if userPath != "" {
return userPath
}
path, err := os.Getwd()
if err != nil {
log.Fatalln(err, path)
}
return strings.TrimSpace(path)
}
func displayTitle(b *check.Break) {
fmt.Println("(For details, please consult https://github.com/Prytoegrian/check-break#what-is-a-compatibility-break-)")
if !b.HasConfiguration() {
fmt.Println("No config file found, checking without one")
} else {
fmt.Println("Using a config file")
}
fmt.Println()
}
func displayBreaks(report *check.BreakReport) {
if 0 == len(report.Supported) {
fmt.Println("> No compatibility break")
fmt.Println()
} else {
fmt.Println("> Potentials compatibility breaks")
for _, fileReport := range report.Supported {
fmt.Println(fileReport.Report())
}
}
}
func displayIgnored(report *check.BreakReport) {
if 0 != len(report.Ignored) {
fmt.Println("> Unsupported files :")
for _, fileIgnored := range report.Ignored {
fmt.Println(fileIgnored.Report())
}
}
}
func displayExclusions(r *check.BreakReport) {
if 0 != len(r.Exclusions) {
fmt.Println("\n> Excluded paths :")
for _, e := range r.Exclusions {
fmt.Println(">>", e)
}
}
}