forked from k1LoW/runn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalias.go
More file actions
49 lines (41 loc) · 1.85 KB
/
alias.go
File metadata and controls
49 lines (41 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package runn
import (
"github.com/k1LoW/runn/internal/expr"
"github.com/k1LoW/runn/internal/exprtrace"
"github.com/k1LoW/runn/internal/scope"
)
const (
AllowReadParent = scope.AllowReadParent
AllowReadRemote = scope.AllowReadRemote
AllowRunExec = scope.AllowRunExec //nostyle:repetition
)
// EvalWithTrace evaluates an expression with tracing and returns the evaluation result with trace information.
// This is useful for debugging expressions and understanding how they are evaluated.
func EvalWithTrace(e string, store exprtrace.EvalEnv) (*exprtrace.EvalResult, error) {
return expr.EvalWithTrace(e, store)
}
// Eval evaluates an expression using the provided environment store and returns the result.
func Eval(e string, store exprtrace.EvalEnv) (any, error) {
return expr.Eval(e, store)
}
// EvalAny evaluate any type. but, EvalAny do not evaluate map key.
// EvalAny evaluates any type of value, recursively evaluating expressions in strings.
// Note that map keys are not evaluated.
func EvalAny(e any, store exprtrace.EvalEnv) (any, error) {
return expr.EvalAny(e, store)
}
// EvalCond evaluates a condition expression and returns a boolean result.
func EvalCond(cond string, store exprtrace.EvalEnv) (bool, error) {
return expr.EvalCond(cond, store)
}
// EvalCount evaluates an expression that should result in an integer value.
// This is typically used for loop counts or other numeric expressions.
func EvalCount(count string, store exprtrace.EvalEnv) (int, error) {
return expr.EvalCount(count, store)
}
// EvalExpand evaluates `in` and expand `{{ }}` in `in` using `store`.
// EvalExpand evaluates an input value and expands any expressions in {{ }} using the provided store.
// This is used for template-like string interpolation within configuration values.
func EvalExpand(in any, store exprtrace.EvalEnv) (any, error) {
return expr.EvalExpand(in, store)
}