-
Notifications
You must be signed in to change notification settings - Fork 324
/
main.go
50 lines (43 loc) · 1.19 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
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Tetragon
package main
import (
"os"
"time"
"github.com/cilium/tetragon/cmd/tetra/common"
"github.com/cilium/tetragon/pkg/logger"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
var (
rootCmd *cobra.Command
)
func main() {
if err := New().Execute(); err != nil {
os.Exit(1)
}
}
func New() *cobra.Command {
rootCmd = &cobra.Command{
Use: "tetra",
Short: "Tetragon CLI",
SilenceUsage: true,
Run: func(cmd *cobra.Command, _ []string) {
cmd.Help()
},
PersistentPreRun: func(_ *cobra.Command, _ []string) {
if common.Debug {
logger.DefaultLogger.SetLevel(logrus.DebugLevel)
}
},
}
// by default, it fallbacks to stderr
rootCmd.SetOut(os.Stdout)
addCommands(rootCmd)
flags := rootCmd.PersistentFlags()
flags.BoolVarP(&common.Debug, common.KeyDebug, "d", false, "Enable debug messages")
flags.StringVar(&common.ServerAddress, common.KeyServerAddress, "", "gRPC server address")
flags.DurationVar(&common.Timeout, common.KeyTimeout, 10*time.Second, "Connection timeout")
flags.IntVar(&common.Retries, common.KeyRetries, 0, "Connection retries with exponential backoff")
return rootCmd
}