mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Added docs
This commit is contained in:
parent
d8324dee0d
commit
fdce8fce13
@ -1,3 +1,8 @@
|
|||||||
|
# Divide
|
||||||
|
|
||||||
|
Divide behaves differently according to the type of the LHS:
|
||||||
|
* strings: split by the divider
|
||||||
|
* number: arithmetic division
|
||||||
|
|
||||||
## String split
|
## String split
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# Filter
|
||||||
|
|
||||||
|
Filters an array (or map values) by the expression given. Equivalent to doing `map(select(exp))`.
|
||||||
|
|
||||||
|
|
||||||
## Filter array
|
## Filter array
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
@ -16,3 +20,23 @@ will output
|
|||||||
- 2
|
- 2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Filter map values
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
c:
|
||||||
|
things: cool
|
||||||
|
frog: yes
|
||||||
|
d:
|
||||||
|
things: hot
|
||||||
|
frog: false
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq 'filter(.things == "cool")' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
- things: cool
|
||||||
|
frog: yes
|
||||||
|
```
|
||||||
|
|
||||||
|
5
pkg/yqlib/doc/operators/headers/divide.md
Normal file
5
pkg/yqlib/doc/operators/headers/divide.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Divide
|
||||||
|
|
||||||
|
Divide behaves differently according to the type of the LHS:
|
||||||
|
* strings: split by the divider
|
||||||
|
* number: arithmetic division
|
4
pkg/yqlib/doc/operators/headers/filter.md
Normal file
4
pkg/yqlib/doc/operators/headers/filter.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Filter
|
||||||
|
|
||||||
|
Filters an array (or map values) by the expression given. Equivalent to doing `map(select(exp))`.
|
||||||
|
|
3
pkg/yqlib/doc/operators/headers/modulo.md
Normal file
3
pkg/yqlib/doc/operators/headers/modulo.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Modulo
|
||||||
|
|
||||||
|
Arithmetic modulo operator, returns the remainder from dividing two numbers.
|
@ -1,4 +1,6 @@
|
|||||||
|
# Modulo
|
||||||
|
|
||||||
|
Arithmetic modulo operator, returns the remainder from dividing two numbers.
|
||||||
## Number modulo - int
|
## Number modulo - int
|
||||||
If the lhs and rhs are ints then the expression will be calculated with ints.
|
If the lhs and rhs are ints then the expression will be calculated with ints.
|
||||||
|
|
||||||
|
@ -13,6 +13,14 @@ var filterOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[], (!!seq)::[1, 2]\n",
|
"D0, P[], (!!seq)::[1, 2]\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "Filter map values",
|
||||||
|
document: `{c: {things: cool, frog: yes}, d: {things: hot, frog: false}}`,
|
||||||
|
expression: `filter(.things == "cool")`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[], (!!seq)::[{things: cool, frog: yes}]\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
document: `[1,2,3]`,
|
document: `[1,2,3]`,
|
||||||
|
Loading…
Reference in New Issue
Block a user