added plugin detected

This commit is contained in:
2021-07-13 23:28:45 +04:00
parent 02f72209dc
commit 63f570bb4f
3 changed files with 30 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import (
"git.sr.ht/~akilan1999/p2p-rendering-computation/client"
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
"git.sr.ht/~akilan1999/p2p-rendering-computation/plugin"
"git.sr.ht/~akilan1999/p2p-rendering-computation/server"
"github.com/urfave/cli/v2"
)
@@ -124,6 +125,16 @@ var CliAction = func(ctx *cli.Context) error {
}
}
// If the view plugin flag is called then display all
// plugins available
if ViewPlugin {
plugins ,err := plugin.DetectPlugins()
if err != nil {
fmt.Print(err)
}
client.PrettyPrint(plugins)
}
return nil
}

View File

@@ -20,6 +20,7 @@ var (
ServerList bool
SetDefaultConfig bool
NetworkInterface bool
ViewPlugin bool
)
var AppConfigFlags = []cli.Flag{
@@ -122,4 +123,11 @@ var AppConfigFlags = []cli.Flag{
EnvVars: []string{"NETWORK_INTERFACE"},
Destination: &NetworkInterface,
},
&cli.BoolFlag{
Name: "ViewPlugins",
Aliases: []string{"vp"},
Usage: "Shows plugins available to be executed",
EnvVars: []string{"VIEW_PLUGIN"},
Destination: &ViewPlugin,
},
}

11
plugin/plugin_test.go Normal file
View File

@@ -0,0 +1,11 @@
package plugin
import "testing"
// Test if the dummy plugin added is detected
func TestDetectPlugins(t *testing.T) {
_, err := DetectPlugins()
if err != nil {
t.Fail()
}
}