Add -outputfilter flag, and refactor the filter flag to work for -sample-config
Closes #211 Issue #199
This commit is contained in:
23
config.go
23
config.go
@@ -384,15 +384,16 @@ var header2 = `
|
||||
###############################################################################
|
||||
`
|
||||
|
||||
// PrintSampleConfig prints the sample config!
|
||||
func PrintSampleConfig() {
|
||||
// PrintSampleConfig prints the sample config
|
||||
func PrintSampleConfig(pluginFilters []string, outputFilters []string) {
|
||||
fmt.Printf(header)
|
||||
|
||||
// Print Outputs
|
||||
var onames []string
|
||||
|
||||
for oname := range outputs.Outputs {
|
||||
onames = append(onames, oname)
|
||||
if len(outputFilters) == 0 || sliceContains(oname, outputFilters) {
|
||||
onames = append(onames, oname)
|
||||
}
|
||||
}
|
||||
sort.Strings(onames)
|
||||
|
||||
@@ -414,9 +415,10 @@ func PrintSampleConfig() {
|
||||
|
||||
// Print Plugins
|
||||
var pnames []string
|
||||
|
||||
for pname := range plugins.Plugins {
|
||||
pnames = append(pnames, pname)
|
||||
if len(pluginFilters) == 0 || sliceContains(pname, pluginFilters) {
|
||||
pnames = append(pnames, pname)
|
||||
}
|
||||
}
|
||||
sort.Strings(pnames)
|
||||
|
||||
@@ -435,6 +437,15 @@ func PrintSampleConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
func sliceContains(name string, list []string) bool {
|
||||
for _, b := range list {
|
||||
if b == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// PrintPluginConfig prints the config usage of a single plugin.
|
||||
func PrintPluginConfig(name string) error {
|
||||
if creator, ok := plugins.Plugins[name]; ok {
|
||||
|
||||
Reference in New Issue
Block a user