mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 22:44:50 +08:00
Comments in yq expressions! #1919
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# Formatting Expressions
|
||||
|
||||
`From version v4.41+`
|
||||
|
||||
You can put expressions into `.yq` files, use whitespace and comments to break up complex expressions and explain what's going on.
|
||||
|
||||
## Using expression files and comments
|
||||
Given a sample.yaml file of:
|
||||
```yaml
|
||||
a:
|
||||
b: old
|
||||
```
|
||||
And an 'update.yq' expression file of:
|
||||
```bash
|
||||
# This is a yq expression that updates the map
|
||||
# for several great reasons outlined here.
|
||||
|
||||
.a.b = "new" # line comment here
|
||||
| .a.c = "frog"
|
||||
|
||||
# Now good things will happen.
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq --from-file update.yq sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a:
|
||||
b: new
|
||||
c: frog
|
||||
```
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Formatting Expressions
|
||||
|
||||
`From version v4.41+`
|
||||
|
||||
You can put expressions into `.yq` files, use whitespace and comments to break up complex expressions and explain what's going on.
|
||||
@@ -370,7 +370,7 @@ cat: purrs
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -o=xml '.' sample.yml
|
||||
yq -o=xml sample.yml
|
||||
```
|
||||
will output
|
||||
```xml
|
||||
@@ -387,7 +387,7 @@ pets:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -o=xml '.' sample.yml
|
||||
yq -o=xml sample.yml
|
||||
```
|
||||
will output
|
||||
```xml
|
||||
@@ -409,7 +409,7 @@ cat:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -o=xml '.' sample.yml
|
||||
yq -o=xml sample.yml
|
||||
```
|
||||
will output
|
||||
```xml
|
||||
@@ -430,7 +430,7 @@ cat:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -o=xml '.' sample.yml
|
||||
yq -o=xml sample.yml
|
||||
```
|
||||
will output
|
||||
```xml
|
||||
@@ -457,7 +457,7 @@ cat: # inline_cat
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -o=xml '.' sample.yml
|
||||
yq -o=xml sample.yml
|
||||
```
|
||||
will output
|
||||
```xml
|
||||
@@ -487,7 +487,7 @@ apple:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq -o=xml '.' sample.yml
|
||||
yq -o=xml sample.yml
|
||||
```
|
||||
will output
|
||||
```xml
|
||||
|
||||
Reference in New Issue
Block a user