mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-07 06:10:36 +00:00
wip
This commit is contained in:
parent
2c7cce0878
commit
6c0f296574
@ -232,7 +232,7 @@ yq '.a += "3h10m"' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
a: 2021-01-01T03:10:00Z
|
a: 2021-01-01T00:00:00Z3h10m
|
||||||
```
|
```
|
||||||
|
|
||||||
## Date addition - custom format
|
## Date addition - custom format
|
||||||
|
|||||||
@ -248,12 +248,6 @@ then
|
|||||||
yq 'explode(.f)' sample.yml
|
yq 'explode(.f)' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
|
||||||
f:
|
|
||||||
a: cat
|
|
||||||
cat: b
|
|
||||||
```
|
|
||||||
|
|
||||||
## Explode with merge anchors
|
## Explode with merge anchors
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@ -152,7 +152,7 @@ will output
|
|||||||
fc: ""
|
fc: ""
|
||||||
- p: name.0
|
- p: name.0
|
||||||
isKey: false
|
isKey: false
|
||||||
hc: under-name-comment
|
hc: ""
|
||||||
lc: ""
|
lc: ""
|
||||||
fc: ""
|
fc: ""
|
||||||
```
|
```
|
||||||
@ -172,7 +172,7 @@ yq '.name[0] | headComment' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
under-name-comment
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Set head comment
|
## Set head comment
|
||||||
@ -258,7 +258,7 @@ yq '... comments=""' sample.yml
|
|||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
a: cat
|
a: cat
|
||||||
b:
|
b: null
|
||||||
```
|
```
|
||||||
|
|
||||||
## Get line comment
|
## Get line comment
|
||||||
@ -293,7 +293,6 @@ yq '. | head_comment' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
welcome!
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -313,8 +312,7 @@ yq 'head_comment' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
welcome!
|
|
||||||
bob
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Get foot comment
|
## Get foot comment
|
||||||
@ -333,7 +331,6 @@ yq '. | foot_comment' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
have a great day
|
|
||||||
no really
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -170,7 +170,7 @@ yq '.a += "3h10m"' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
a: 2021-01-01T03:10:00Z
|
a: 2021-01-01T00:00:00Z3h10m
|
||||||
```
|
```
|
||||||
|
|
||||||
## Date subtraction
|
## Date subtraction
|
||||||
@ -185,10 +185,6 @@ then
|
|||||||
yq '.a -= "3h10m"' sample.yml
|
yq '.a -= "3h10m"' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
|
||||||
a: 2021-01-01T00:00:00Z
|
|
||||||
```
|
|
||||||
|
|
||||||
## Date addition - custom format
|
## Date addition - custom format
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@ -109,7 +109,7 @@ yq '.a.x | key | headComment' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
comment on key
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Check node is a key
|
## Check node is a key
|
||||||
|
|||||||
@ -105,10 +105,6 @@ then
|
|||||||
yq '.a -= "3h10m"' sample.yml
|
yq '.a -= "3h10m"' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
|
||||||
a: 2021-01-01T00:00:00Z
|
|
||||||
```
|
|
||||||
|
|
||||||
## Date subtraction - custom format
|
## 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.
|
Use with_dtf to specify your datetime format. See [date-time operators](https://mikefarah.gitbook.io/yq/operators/date-time-operators) for more information.
|
||||||
|
|
||||||
|
|||||||
@ -55,30 +55,30 @@ var goccyYamlFormatScenarios = []formatScenario{
|
|||||||
// input: "[3]",
|
// input: "[3]",
|
||||||
// expected: "[3]\n",
|
// expected: "[3]\n",
|
||||||
// },
|
// },
|
||||||
// {
|
{
|
||||||
// description: "basic - plain string",
|
description: "basic - plain string",
|
||||||
// skipDoc: true,
|
skipDoc: true,
|
||||||
// input: `a: meow`,
|
input: `a: meow`,
|
||||||
// expected: "a: meow\n",
|
expected: "a: meow\n",
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// description: "basic - double quoted string",
|
description: "basic - double quoted string",
|
||||||
// skipDoc: true,
|
skipDoc: true,
|
||||||
// input: `a: "meow"`,
|
input: `a: "meow"`,
|
||||||
// expected: "a: \"meow\"\n",
|
expected: "a: \"meow\"\n",
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// description: "basic - single quoted string",
|
description: "basic - single quoted string",
|
||||||
// skipDoc: true,
|
skipDoc: true,
|
||||||
// input: `a: 'meow'`,
|
input: `a: 'meow'`,
|
||||||
// expected: "a: 'meow'\n",
|
expected: "a: 'meow'\n",
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// description: "basic - string block",
|
description: "basic - string block",
|
||||||
// skipDoc: true,
|
skipDoc: true,
|
||||||
// input: "a: |\n meow\n",
|
input: "a: |\n meow\n",
|
||||||
// expected: "a: |\n meow\n",
|
expected: "a: |\n meow\n",
|
||||||
// },
|
},
|
||||||
// {
|
// {
|
||||||
// description: "basic - long string",
|
// description: "basic - long string",
|
||||||
// skipDoc: true,
|
// skipDoc: true,
|
||||||
|
|||||||
15
pkg/yqlib/single_test.go
Normal file
15
pkg/yqlib/single_test.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package yqlib
|
||||||
|
|
||||||
|
// func TestSingScenarioForDebugging(t *testing.T) {
|
||||||
|
// logging.SetLevel(logging.DEBUG, "")
|
||||||
|
// testScenario(t, &expressionScenario{
|
||||||
|
// description: "Dont explode alias and anchor - check alias parent",
|
||||||
|
// skipDoc: true,
|
||||||
|
// document: `{a: &a [1], b: *a}`,
|
||||||
|
// expression: `.b[0]`,
|
||||||
|
// expected: []string{
|
||||||
|
// "D0, P[a 0], (!!int)::1\n",
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// logging.SetLevel(logging.ERROR, "")
|
||||||
|
// }
|
||||||
Loading…
Reference in New Issue
Block a user