/
root.go
42 lines (33 loc) · 877 Bytes
/
root.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
package cmd
import (
"fmt"
"log"
"github.com/danbudris/vulnerabilityProcessor/pkg/logger"
"github.com/spf13/cobra"
)
const (
vexFilepathFlag = "vexFilepath"
)
var rootCmd = &cobra.Command{
Use: "vulnerability-processor",
Short: "Initialize Vulnerability Router and Processor",
Long: `Route and process vulnerabilities based on your defined workflow`,
PersistentPreRun: rootPersistentPreRun,
}
func init() {
rootCmd.PersistentFlags().IntP("verbosity", "v", 0, "Set the log level verbosity")
}
func rootPersistentPreRun(cmd *cobra.Command, args []string) {
if err := initLogger(); err != nil {
log.Fatal(err)
}
}
func initLogger() error {
if err := logger.InitZap(6); err != nil {
return fmt.Errorf("failed init zap logger in root command: %v", err)
}
return nil
}
func Execute() error {
return rootCmd.Execute()
}