File: func_key.go

package info (click to toggle)
dasel 2.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,844 kB
  • sloc: sh: 53; python: 21; makefile: 21; xml: 20
file content (24 lines) | stat: -rw-r--r-- 402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package dasel

var KeyFunc = BasicFunction{
	name: "key",
	runFn: func(c *Context, s *Step, args []string) (Values, error) {
		if err := requireNoArgs("key", args); err != nil {
			return nil, err
		}

		input := s.inputs()

		res := make(Values, 0)

		for _, i := range input {
			p := i.Metadata("key")
			if p == nil {
				continue
			}
			res = append(res, ValueOf(p))
		}

		return res, nil
	},
}