1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Can assign-update aliases and anchors

This commit is contained in:
Mike Farah
2021-01-06 20:30:48 +11:00
parent a7975df7cd
commit 3f58c4bc38
3 changed files with 90 additions and 13 deletions

View File

@@ -31,6 +31,22 @@ will output
a: &foobar cat
```
## Set anchor relatively using assign-update
Given a sample.yml file of:
```yaml
a:
b: cat
```
then
```bash
yq eval '.a anchor |= .b' sample.yml
```
will output
```yaml
a: &cat
b: cat
```
## Get alias
Given a sample.yml file of:
```yaml
@@ -62,6 +78,23 @@ b: &meow purr
a: *meow
```
## Set alias relatively using assign-update
Given a sample.yml file of:
```yaml
b: &meow purr
a:
f: meow
```
then
```bash
yq eval '.a alias |= .f' sample.yml
```
will output
```yaml
b: &meow purr
a: *meow
```
## Explode alias and anchor
Given a sample.yml file of:
```yaml