updating docs

This commit is contained in:
Mike Farah 2024-09-06 12:33:38 +10:00
parent 1f1efb08ad
commit 57e4639631
2 changed files with 31 additions and 0 deletions

View File

@ -1,3 +1,10 @@
# Kind
The `kind` operator identifies the type of a node as either `scalar`, `map`, or `seq`.
This can be used for filtering or transforming nodes based on their type.
Note that `null` values are treated as `scalar`.
## Get kind ## Get kind
Given a sample.yml file of: Given a sample.yml file of:

View File

@ -26,6 +26,30 @@ myMap:
cat: meow cat: meow
``` ```
## Pick keys from map, included all the keys
We create a map of the picked keys plus all the current keys, and run that through unique
Given a sample.yml file of:
```yaml
myMap:
cat: meow
dog: bark
thing: hamster
hamster: squeak
```
then
```bash
yq '.myMap |= pick( (["thing"] + keys) | unique)' sample.yml
```
will output
```yaml
myMap:
thing: hamster
cat: meow
dog: bark
hamster: squeak
```
## Pick indices from array ## Pick indices from array
Note that the order of the indices matches the pick order and non existent indices are skipped. Note that the order of the indices matches the pick order and non existent indices are skipped.