New function for searching and importing plugin
This commit is contained in:
+2
-24
@@ -4,10 +4,6 @@
|
||||
// operator-plugin.go
|
||||
package expr
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
//-------- plugin term
|
||||
|
||||
func newPluginTerm(tk *Token) (inst *term) {
|
||||
@@ -22,31 +18,13 @@ func newPluginTerm(tk *Token) (inst *term) {
|
||||
|
||||
func evalPlugin(ctx ExprContext, opTerm *term) (v any, err error) {
|
||||
var childValue any
|
||||
var moduleSpec any
|
||||
var count int
|
||||
|
||||
if childValue, err = opTerm.evalPrefix(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
dirList := buildSearchDirList("plugin", ENV_EXPR_PLUGIN_PATH)
|
||||
count := 0
|
||||
it := NewAnyIterator(childValue)
|
||||
for moduleSpec, err = it.Next(); err == nil; moduleSpec, err = it.Next() {
|
||||
if module, ok := moduleSpec.(string); ok {
|
||||
if err = importPlugin(dirList, module); err != nil {
|
||||
break
|
||||
}
|
||||
count++
|
||||
} else {
|
||||
err = opTerm.Errorf("expected string as item nr %d, got %s", it.Index()+1, TypeName(moduleSpec))
|
||||
break
|
||||
}
|
||||
}
|
||||
if err == io.EOF {
|
||||
err = nil
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
if count, err = importPluginFromSearchPath(childValue); err == nil {
|
||||
v = int64(count)
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user