forked from StephanU/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
47 lines (34 loc) · 749 Bytes
/
cli.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
//+build linux,go1.8,cgo
package plugin
import (
"flag"
"strings"
"github.com/elastic/beats/libbeat/logp"
)
type pluginList struct {
paths []string
}
func (p *pluginList) String() string {
return strings.Join(p.paths, ",")
}
func (p *pluginList) Set(v string) error {
// TODO: check file exists
p.paths = append(p.paths, v)
return nil
}
var plugins = &pluginList{}
func init() {
flag.Var(plugins, "plugin", "Load additional plugins")
}
func Initialize() error {
if len(plugins.paths) > 0 {
logp.Warn("EXPERIMENTAL: loadable plugin support is experimental")
}
for _, path := range plugins.paths {
logp.Info("loading plugin bundle: %v", path)
if err := LoadPlugins(path); err != nil {
return err
}
}
return nil
}