Kaynağa Gözat

List plugins

Signed-off-by: Marius Karnauskas <marius.karnauskas@gmail.com>
Marius Karnauskas 5 yıl önce
ebeveyn
işleme
e080c7407a

+ 10 - 0
cmds/coredhcp-generator/coredhcp.go.template

@@ -12,6 +12,7 @@ import (
 	"flag"
 	"fmt"
 	"io/ioutil"
+	"os"
 	"time"
 
 	"github.com/coredhcp/coredhcp/config"
@@ -32,6 +33,7 @@ var (
 	flagLogNoStdout = flag.Bool("nostdout", false, "Disable logging to stdout/stderr")
 	flagLogLevel    = flag.String("loglevel", "info", fmt.Sprintf("Log level. One of %v", getLogLevels()))
 	flagConfig      = flag.String("conf", "", "Use this configuration file instead of the default location")
+	flagPlugins     = flag.Bool("plugins", false, "list plugins")
 )
 
 var logLevels = map[string]func(*logrus.Logger){
@@ -59,6 +61,14 @@ var desiredPlugins = []*plugins.Plugin{
 
 func main() {
 	flag.Parse()
+
+	if *flagPlugins {
+		for _, p := range desiredPlugins {
+			fmt.Println(p.Name)
+		}
+		os.Exit(0)
+	}
+
 	log := logger.GetLogger("main")
 	fn, ok := logLevels[*flagLogLevel]
 	if !ok {

+ 10 - 0
cmds/coredhcp/main.go

@@ -11,6 +11,7 @@ import (
 	"flag"
 	"fmt"
 	"io/ioutil"
+	"os"
 	"time"
 
 	"github.com/coredhcp/coredhcp/config"
@@ -35,6 +36,7 @@ var (
 	flagLogNoStdout = flag.Bool("nostdout", false, "Disable logging to stdout/stderr")
 	flagLogLevel    = flag.String("loglevel", "info", fmt.Sprintf("Log level. One of %v", getLogLevels()))
 	flagConfig      = flag.String("conf", "", "Use this configuration file instead of the default location")
+	flagPlugins     = flag.Bool("plugins", false, "list plugins")
 )
 
 var logLevels = map[string]func(*logrus.Logger){
@@ -67,6 +69,14 @@ var desiredPlugins = []*plugins.Plugin{
 
 func main() {
 	flag.Parse()
+
+	if *flagPlugins {
+		for _, p := range desiredPlugins {
+			fmt.Println(p.Name)
+		}
+		os.Exit(0)
+	}
+
 	log := logger.GetLogger("main")
 	fn, ok := logLevels[*flagLogLevel]
 	if !ok {