Provide a -usage flag for printing the usage of a single plugin

Closes #136
This commit is contained in:
Cameron Sparr
2015-08-24 14:52:46 -06:00
parent 50f902cb02
commit 42602a3f35
2 changed files with 27 additions and 3 deletions

View File

@@ -421,3 +421,15 @@ func PrintSampleConfig() {
}
}
}
// PrintPluginConfig prints the config usage of a single plugin.
func PrintPluginConfig(name string) error {
if creator, ok := plugins.Plugins[name]; ok {
plugin := creator()
fmt.Printf("# %s\n[%s]\n", plugin.Description(), name)
fmt.Printf(strings.TrimSpace(plugin.SampleConfig()))
} else {
return errors.New(fmt.Sprintf("Plugin %s not found", name))
}
return nil
}