Quellcode durchsuchen

feat: cli permission helper

Yeuoly vor 11 Monaten
Ursprung
Commit
0cfa74115f
2 geänderte Dateien mit 53 neuen und 11 gelöschten Zeilen
  1. 0 11
      cmd/commandline/main.go
  2. 53 0
      cmd/commandline/plugin.go

+ 0 - 11
cmd/commandline/main.go

@@ -4,7 +4,6 @@ import (
 	"fmt"
 	"os"
 
-	"github.com/langgenius/dify-plugin-daemon/cmd/commandline/cmd"
 	"github.com/spf13/cobra"
 	"github.com/spf13/viper"
 )
@@ -23,15 +22,6 @@ var (
 		Short: "Plugin",
 		Long:  "Plugin related commands",
 	}
-
-	pluginInitCommand = &cobra.Command{
-		Use:   "init",
-		Short: "Init",
-		Long:  "Init",
-		Run: func(c *cobra.Command, args []string) {
-			cmd.InitPlugin()
-		},
-	}
 )
 
 func init() {
@@ -39,7 +29,6 @@ func init() {
 
 	rootCommand.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.dify.yaml)")
 	rootCommand.AddCommand(pluginCommand)
-	pluginCommand.AddCommand(pluginInitCommand)
 }
 
 func initConfig() {

+ 53 - 0
cmd/commandline/plugin.go

@@ -0,0 +1,53 @@
+package main
+
+import (
+	"github.com/langgenius/dify-plugin-daemon/cmd/commandline/cmd"
+	"github.com/spf13/cobra"
+)
+
+var (
+	pluginInitCommand = &cobra.Command{
+		Use:   "init",
+		Short: "Init",
+		Long:  "Init",
+		Run: func(c *cobra.Command, args []string) {
+			cmd.InitPlugin()
+		},
+	}
+
+	pluginPermissionCommand = &cobra.Command{
+		Use:   "permission",
+		Short: "Permission",
+		Long: `Permission, available values: 
+tools					- allow plugin to call tools
+models					- allow plugin to call models
+models.llm				- allow plugin to call llm
+models.text_embedding			- allow plugin to call text_embedding model
+models.rerank				- allow plugin to call rerank model
+models.tts				- allow plugin to call tts
+models.speech2text			- allow plugin to call speech2text
+models.moderation			- allow plugin to call moderation
+apps					- allow plugin to call apps
+storage					- allow plugin to use storage
+endpoint				- allow plugin to register endpoint`,
+	}
+
+	pluginPermissionAddCommand = &cobra.Command{
+		Use:   "add",
+		Short: "Add permission to plugin",
+		Long:  "Add permission to plugin, you can find the available permission by running `dify plugin permission`",
+	}
+
+	pluginPermissionDropCommand = &cobra.Command{
+		Use:   "drop",
+		Short: "Drop permission from plugin",
+		Long:  "Drop permission from plugin, you can find the available permission by running `dify plugin permission`",
+	}
+)
+
+func init() {
+	pluginCommand.AddCommand(pluginInitCommand)
+	pluginCommand.AddCommand(pluginPermissionCommand)
+	pluginPermissionCommand.AddCommand(pluginPermissionAddCommand)
+	pluginPermissionCommand.AddCommand(pluginPermissionDropCommand)
+}