simplify pluginsdir

This commit is contained in:
Roy Crihfield 2023-06-29 15:57:24 +08:00
parent 80e02c90e3
commit 1a40a8f776
3 changed files with 4 additions and 11 deletions

View File

@ -20,7 +20,6 @@ package geth
import (
"fmt"
"os"
"path"
"sort"
"strconv"
"strings"
@ -342,14 +341,7 @@ func prepare(ctx *cli.Context) {
// blocking mode, waiting for it to be shut down.
func geth(ctx *cli.Context) error {
//begin PluGeth code injection
var pluginsDir string
if ctx.IsSet(utils.PluginsDirFlag.Name) {
pluginsDir = ctx.String(utils.PluginsDirFlag.Name)
} else {
pluginsDir = path.Join(ctx.String(utils.DataDirFlag.Name), "plugins")
}
if err := plugins.Initialize(pluginsDir, ctx); err != nil {
if err := plugins.Initialize(ctx.String(utils.PluginsDirFlag.Name), ctx); err != nil {
return err
}
prepare(ctx)

View File

@ -91,7 +91,8 @@ var (
//begin PluGeth code injection
PluginsDirFlag = &flags.DirectoryFlag{
Name: "pluginsdir",
Usage: "Directory for plugins (default = datadir/plugins)",
Usage: "Directory for plugins",
Value: flags.DirectoryString(filepath.Join(node.DefaultDataDir(), "plugins")),
Category: flags.EthCategory,
}
//end PluGeth code injection

View File

@ -58,7 +58,7 @@ func Lookup(name string, validate func(interface{}) bool) []interface{} {
var DefaultPluginLoader *PluginLoader
func NewPluginLoader(target string) (*PluginLoader, error) {
log.Info("Loading plugins from directory.", "path", target)
log.Info("Loading plugins from directory", "path", target)
pl := &PluginLoader{
Plugins: []pluginDetails{},
Subcommands: make(map[string]Subcommand),