mirror of
https://github.com/mikefarah/yq.git
synced 2026-03-10 15:54:26 +00:00
wip
This commit is contained in:
parent
2c7cce0878
commit
6c0f296574
@ -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.
|
||||
|
||||
|
||||
@ -55,30 +55,30 @@ var goccyYamlFormatScenarios = []formatScenario{
|
||||
// input: "[3]",
|
||||
// expected: "[3]\n",
|
||||
// },
|
||||
// {
|
||||
// description: "basic - plain string",
|
||||
// skipDoc: true,
|
||||
// input: `a: meow`,
|
||||
// expected: "a: meow\n",
|
||||
// },
|
||||
// {
|
||||
// description: "basic - double quoted string",
|
||||
// skipDoc: true,
|
||||
// input: `a: "meow"`,
|
||||
// expected: "a: \"meow\"\n",
|
||||
// },
|
||||
// {
|
||||
// description: "basic - single quoted string",
|
||||
// skipDoc: true,
|
||||
// input: `a: 'meow'`,
|
||||
// expected: "a: 'meow'\n",
|
||||
// },
|
||||
// {
|
||||
// description: "basic - string block",
|
||||
// skipDoc: true,
|
||||
// input: "a: |\n meow\n",
|
||||
// expected: "a: |\n meow\n",
|
||||
// },
|
||||
{
|
||||
description: "basic - plain string",
|
||||
skipDoc: true,
|
||||
input: `a: meow`,
|
||||
expected: "a: meow\n",
|
||||
},
|
||||
{
|
||||
description: "basic - double quoted string",
|
||||
skipDoc: true,
|
||||
input: `a: "meow"`,
|
||||
expected: "a: \"meow\"\n",
|
||||
},
|
||||
{
|
||||
description: "basic - single quoted string",
|
||||
skipDoc: true,
|
||||
input: `a: 'meow'`,
|
||||
expected: "a: 'meow'\n",
|
||||
},
|
||||
{
|
||||
description: "basic - string block",
|
||||
skipDoc: true,
|
||||
input: "a: |\n meow\n",
|
||||
expected: "a: |\n meow\n",
|
||||
},
|
||||
// {
|
||||
// description: "basic - long string",
|
||||
// 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