/
services.go
45 lines (37 loc) · 918 Bytes
/
services.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
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
const (
svcsUse = "services"
svcsShort = "Show list of service names this receptor will collect evidence for"
)
type svcs struct {
cmd *cobra.Command
}
func (s *svcs) getCommand() *cobra.Command {
return s.cmd
}
func (s *svcs) setup() {
s.cmd = &cobra.Command{
Use: svcsUse,
Short: svcsShort,
Args: cobra.MinimumNArgs(0),
RunE: services,
SilenceUsage: true,
}
s.cmd.FParseErrWhitelist.UnknownFlags = true
}
// Cobra executes this function on services command.
func services(_ *cobra.Command, args []string) (err error) {
serviceNames := receptorImpl.GetKnownServices()
if len(serviceNames) > 0 {
for _, name := range serviceNames {
fmt.Println(name)
}
}
return
}