Update document generation script

This commit is contained in:
Mike Farah
2021-11-03 15:00:28 +11:00
parent 5bedd759a8
commit a41131816a
34 changed files with 111 additions and 1337 deletions
+2 -18
View File
@@ -3,24 +3,18 @@
This is operation that returns true if the key exists in a map (or index in an array), false otherwise.
## Has map key
Given a sample.yml file of:
```yaml
- a: yes
- a: ~
- a:
- b: nope
```
then
```bash
yq eval '.[] | has("a")' sample.yml
```
will output
```yaml
true
true
@@ -29,11 +23,9 @@ false
```
## Select, checking for existence of deep paths
Simply pipe in parent expressions into `has`
Given a sample.yml file of:
```yaml
- a:
b:
@@ -42,15 +34,11 @@ Given a sample.yml file of:
b:
d: dog
```
then
```bash
yq eval '.[] | select(.a.b | has("c"))' sample.yml
```
will output
```yaml
a:
b:
@@ -58,25 +46,20 @@ a:
```
## Has array index
Given a sample.yml file of:
```yaml
- []
- [1]
- [1, 2]
- [1, null]
- [1, 2, 3]
```
then
```bash
yq eval '.[] | has(1)' sample.yml
```
will output
```yaml
false
false
@@ -84,3 +67,4 @@ true
true
true
```