-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (32 loc) · 950 Bytes
/
main.go
File metadata and controls
41 lines (32 loc) · 950 Bytes
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
package main
import (
"os"
"strings"
"github.com/spf13/cobra"
"github.com/stackrox/rox/pkg/clientconn"
"github.com/stackrox/rox/pkg/sync"
"github.com/stackrox/rox/roxctl/common"
"github.com/stackrox/rox/roxctl/maincommand"
"github.com/stackrox/rox/roxctl/utils"
// Make sure devbuild setting is registered.
_ "github.com/stackrox/rox/pkg/devbuild"
)
func main() {
c := maincommand.Command()
c.SetHelpFunc(utils.FormatHelp)
once := sync.Once{}
// Peak only the deepest command path. The hooks are added to all commands.
common.PatchPersistentPreRunHooks(c, func(cmd *cobra.Command, args []string) {
once.Do(func() {
common.RoxctlCommand = getCommandPath(cmd)
})
})
clientconn.SetUserAgent(clientconn.Roxctl)
if err := c.Execute(); err != nil {
os.Exit(1)
}
}
func getCommandPath(cmd *cobra.Command) string {
binaryName := cmd.Root().CommandPath() + " "
return strings.TrimPrefix(cmd.CommandPath(), binaryName)
}