Add -outputfilter flag, and refactor the filter flag to work for -sample-config

Closes #211
Issue #199
This commit is contained in:
Cameron Sparr
2015-09-21 18:38:57 -07:00
parent 72edc3c4fe
commit ec9819071a
6 changed files with 308 additions and 219 deletions

View File

@@ -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 {