mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-06 13:25:42 +00:00
Merge in master
This commit is contained in:
parent
2869919cb4
commit
8c25f33df4
1
go.sum
1
go.sum
@ -59,7 +59,6 @@ golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
|||||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
|
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
|
||||||
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
|
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 h1:6D+BvnJ/j6e222UW8s2qTSe3wGBtvo0MbVQG/c5k8RE=
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 h1:6D+BvnJ/j6e222UW8s2qTSe3wGBtvo0MbVQG/c5k8RE=
|
||||||
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473/go.mod h1:N1eN2tsCx0Ydtgjl4cqmbRCsY4/+z4cYDeqwZTk6zog=
|
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473/go.mod h1:N1eN2tsCx0Ydtgjl4cqmbRCsY4/+z4cYDeqwZTk6zog=
|
||||||
|
|||||||
@ -1,3 +1,8 @@
|
|||||||
|
# First
|
||||||
|
|
||||||
|
Returns the first matching element in an array, or first matching value in a map.
|
||||||
|
|
||||||
|
Can be given an expression to match with, otherwise will just return the first.
|
||||||
|
|
||||||
## First matching element from array
|
## First matching element from array
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
@ -20,8 +25,10 @@ Given a sample.yml file of:
|
|||||||
```yaml
|
```yaml
|
||||||
- a: banana
|
- a: banana
|
||||||
- a: cat
|
- a: cat
|
||||||
|
b: firstCat
|
||||||
- a: apple
|
- a: apple
|
||||||
- a: cat
|
- a: cat
|
||||||
|
b: secondCat
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
@ -30,6 +37,7 @@ yq 'first(.a == "cat")' sample.yml
|
|||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
a: cat
|
a: cat
|
||||||
|
b: firstCat
|
||||||
```
|
```
|
||||||
|
|
||||||
## First matching element from array with numeric condition
|
## First matching element from array with numeric condition
|
||||||
@ -38,6 +46,7 @@ Given a sample.yml file of:
|
|||||||
- a: 10
|
- a: 10
|
||||||
- a: 100
|
- a: 100
|
||||||
- a: 1
|
- a: 1
|
||||||
|
- a: 101
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
@ -53,7 +62,10 @@ Given a sample.yml file of:
|
|||||||
```yaml
|
```yaml
|
||||||
- a: false
|
- a: false
|
||||||
- a: true
|
- a: true
|
||||||
|
b: firstTrue
|
||||||
- a: false
|
- a: false
|
||||||
|
- a: true
|
||||||
|
b: secondTrue
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
@ -62,6 +74,7 @@ yq 'first(.a == true)' sample.yml
|
|||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
a: true
|
a: true
|
||||||
|
b: firstTrue
|
||||||
```
|
```
|
||||||
|
|
||||||
## First matching element from array with null values
|
## First matching element from array with null values
|
||||||
@ -84,19 +97,19 @@ a: cat
|
|||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
- a: dog
|
- a: dog
|
||||||
b: 5
|
b: 7
|
||||||
- a: cat
|
- a: cat
|
||||||
b: 3
|
b: 3
|
||||||
- a: apple
|
- a: apple
|
||||||
b: 7
|
b: 5
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
yq 'first(.b > 4)' sample.yml
|
yq 'first(.b > 4 and .b < 6)' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
a: dog
|
a: apple
|
||||||
b: 5
|
b: 5
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -127,7 +140,7 @@ x:
|
|||||||
y:
|
y:
|
||||||
a: 100
|
a: 100
|
||||||
z:
|
z:
|
||||||
a: 1
|
a: 101
|
||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@ -11,4 +11,3 @@ func NewDefaultShellVariablesPreferences() ShellVariablesPreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ConfiguredShellVariablesPreferences = NewDefaultShellVariablesPreferences()
|
var ConfiguredShellVariablesPreferences = NewDefaultShellVariablesPreferences()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user