-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.go
46 lines (37 loc) · 831 Bytes
/
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
package main
import (
"fmt"
"os"
"scan2html/internal/common"
"scan2html/internal/logger"
"scan2html/internal/report"
"scan2html/internal/trivy"
)
var (
version = "dev"
)
func main() {
logger.Logger.Info("Scan2html started")
if common.IsHelp() {
helpMessage()
}
pluginFlags, trivyCommand := common.RetrievePluginFlagsAndCommand(os.Args)
var exitCode = 0
if _, exists := pluginFlags["generate"]; exists {
if err := report.CombineReports(pluginFlags); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
} else {
exitCode, _ = trivy.GenerateJsonReport(trivyCommand)
}
err := report.GenerateHtmlReport(pluginFlags, version)
if err != nil {
logger.Logger.Fatalf("Error generating HTML report: %v", err)
}
os.Exit(exitCode)
}
func helpMessage() {
common.PrintHelp(version)
os.Exit(0)
}