MCPcopy
hub / github.com/TomWright/dasel / ExecuteSelector

Function ExecuteSelector

execution/execute.go:16–32  ·  view source on GitHub ↗

ExecuteSelector parses the selector and executes the resulting AST with the given input.

(ctx context.Context, selectorStr string, value *model.Value, opts *Options)

Source from the content-addressed store, hash-verified

14
15// ExecuteSelector parses the selector and executes the resulting AST with the given input.
16func ExecuteSelector(ctx context.Context, selectorStr string, value *model.Value, opts *Options) (*model.Value, error) {
17 if selectorStr == "" {
18 return value, nil
19 }
20
21 expr, err := selector.Parse(selectorStr)
22 if err != nil {
23 return nil, fmt.Errorf("error parsing selector: %w", err)
24 }
25
26 res, err := ExecuteAST(ctx, expr, value, opts)
27 if err != nil {
28 return nil, fmt.Errorf("error executing selector: %w", err)
29 }
30
31 return res, nil
32}
33
34type expressionExecutor func(ctx context.Context, options *Options, data *model.Value) (*model.Value, error)
35

Callers 10

QueryFunction · 0.92
runFunction · 0.92
ReadMethod · 0.92
TestReduceFunction · 0.92
TestErrorsFunction · 0.92
TestGroupByFunction · 0.92
TestMapValuesFunction · 0.92
TestKeyVarFunction · 0.92
runMethod · 0.92
TestVariableFunction · 0.92

Calls 2

ParseFunction · 0.92
ExecuteASTFunction · 0.85

Tested by 7

TestReduceFunction · 0.74
TestErrorsFunction · 0.74
TestGroupByFunction · 0.74
TestMapValuesFunction · 0.74
TestKeyVarFunction · 0.74
runMethod · 0.74
TestVariableFunction · 0.74