Skip to content

Commit

Permalink
feat: cli permission helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Sep 2, 2024
1 parent cb0f14e commit 0cfa741
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
11 changes: 0 additions & 11 deletions cmd/commandline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"os"

"github.com/langgenius/dify-plugin-daemon/cmd/commandline/cmd"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand All @@ -23,23 +22,13 @@ 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() {
cobra.OnInitialize(initConfig)

rootCommand.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.dify.yaml)")
rootCommand.AddCommand(pluginCommand)
pluginCommand.AddCommand(pluginInitCommand)
}

func initConfig() {
Expand Down
53 changes: 53 additions & 0 deletions cmd/commandline/plugin.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 0cfa741

Please sign in to comment.