mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-06 10:04:43 +08:00
wip
This commit is contained in:
@@ -232,7 +232,7 @@ yq '.a += "3h10m"' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a: 2021-01-01T03:10:00Z
|
||||
a: 2021-01-01T00:00:00Z3h10m
|
||||
```
|
||||
|
||||
## Date addition - custom format
|
||||
|
||||
@@ -248,12 +248,6 @@ then
|
||||
yq 'explode(.f)' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
f:
|
||||
a: cat
|
||||
cat: b
|
||||
```
|
||||
|
||||
## Explode with merge anchors
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
|
||||
@@ -152,7 +152,7 @@ will output
|
||||
fc: ""
|
||||
- p: name.0
|
||||
isKey: false
|
||||
hc: under-name-comment
|
||||
hc: ""
|
||||
lc: ""
|
||||
fc: ""
|
||||
```
|
||||
@@ -172,7 +172,7 @@ yq '.name[0] | headComment' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
under-name-comment
|
||||
|
||||
```
|
||||
|
||||
## Set head comment
|
||||
@@ -258,7 +258,7 @@ yq '... comments=""' sample.yml
|
||||
will output
|
||||
```yaml
|
||||
a: cat
|
||||
b:
|
||||
b: null
|
||||
```
|
||||
|
||||
## Get line comment
|
||||
@@ -293,7 +293,6 @@ yq '. | head_comment' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
welcome!
|
||||
|
||||
```
|
||||
|
||||
@@ -313,8 +312,7 @@ yq 'head_comment' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
welcome!
|
||||
bob
|
||||
|
||||
```
|
||||
|
||||
## Get foot comment
|
||||
@@ -333,7 +331,6 @@ yq '. | foot_comment' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
have a great day
|
||||
no really
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ yq '.a += "3h10m"' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a: 2021-01-01T03:10:00Z
|
||||
a: 2021-01-01T00:00:00Z3h10m
|
||||
```
|
||||
|
||||
## Date subtraction
|
||||
@@ -185,10 +185,6 @@ then
|
||||
yq '.a -= "3h10m"' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a: 2021-01-01T00:00:00Z
|
||||
```
|
||||
|
||||
## Date addition - custom format
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
|
||||
@@ -109,7 +109,7 @@ yq '.a.x | key | headComment' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
comment on key
|
||||
|
||||
```
|
||||
|
||||
## Check node is a key
|
||||
|
||||
@@ -105,10 +105,6 @@ then
|
||||
yq '.a -= "3h10m"' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
a: 2021-01-01T00:00:00Z
|
||||
```
|
||||
|
||||
## Date subtraction - custom format
|
||||
Use with_dtf to specify your datetime format. See [date-time operators](https://mikefarah.gitbook.io/yq/operators/date-time-operators) for more information.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user