mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Pass context through operators
Allows more sophisticated functionality
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package yqlib
|
||||
|
||||
import "container/list"
|
||||
|
||||
type Context struct {
|
||||
MatchingNodes *list.List
|
||||
Variables map[string]*list.List
|
||||
}
|
||||
|
||||
func (n *Context) SingleChildContext(candidate *CandidateNode) Context {
|
||||
elMap := list.New()
|
||||
elMap.PushBack(candidate)
|
||||
return Context{MatchingNodes: elMap, Variables: n.Variables}
|
||||
}
|
||||
|
||||
func (n *Context) ChildContext(results *list.List) Context {
|
||||
return Context{MatchingNodes: results, Variables: n.Variables}
|
||||
}
|
||||
Reference in New Issue
Block a user