-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
command.go
39 lines (33 loc) · 923 Bytes
/
command.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
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package hive
import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/cilium/cilium/pkg/logging"
)
// Command constructs the cobra command for hive. The hive
// command can be used to inspect the dependency graph.
func (h *Hive) Command() *cobra.Command {
cmd := &cobra.Command{
Use: "hive",
Short: "Inspect the hive",
Run: func(cmd *cobra.Command, args []string) {
// Silence log messages from calling invokes and constructors.
logging.SetLogLevel(logrus.WarnLevel)
h.PrintObjects()
},
TraverseChildren: false,
}
h.RegisterFlags(cmd.PersistentFlags())
cmd.AddCommand(
&cobra.Command{
Use: "dot-graph",
Short: "Output the dependencies graph in graphviz dot format",
Run: func(cmd *cobra.Command, args []string) {
h.PrintDotGraph()
},
TraverseChildren: false,
})
return cmd
}