-
-
Notifications
You must be signed in to change notification settings - Fork 140
/
step.go
41 lines (35 loc) · 791 Bytes
/
step.go
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
package dasel
// Step is a single step in the query.
// Each function call has its own step.
// Each value in the output is simply a pointer to the actual data point in the context data.
type Step struct {
context *Context
selector Selector
index int
output Values
}
func (s *Step) Selector() Selector {
return s.selector
}
func (s *Step) Index() int {
return s.index
}
func (s *Step) Output() Values {
return s.output
}
func (s *Step) execute() error {
f, err := s.context.functions.Get(s.selector.funcName)
if err != nil {
return err
}
output, err := f(s.context, s, s.selector.funcArgs)
s.output = output
return err
}
func (s *Step) inputs() Values {
prevStep := s.context.Step(s.index - 1)
if prevStep == nil {
return Values{}
}
return prevStep.output
}