diff --git a/cmd/action.go b/cmd/action.go index bf8649a..714566b 100644 --- a/cmd/action.go +++ b/cmd/action.go @@ -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 } diff --git a/cmd/flags.go b/cmd/flags.go index bf927b6..a0e0ba9 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -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, + }, } \ No newline at end of file diff --git a/plugin/plugin_test.go b/plugin/plugin_test.go new file mode 100644 index 0000000..6820dab --- /dev/null +++ b/plugin/plugin_test.go @@ -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() + } +} \ No newline at end of file