mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-23 14:16:10 +00:00
Fixed with semicolon space issue
This commit is contained in:
parent
3339562aa2
commit
2292f0ffb4
@ -9,7 +9,7 @@ a:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq eval 'with(.a.deeply.nested ; . = "newValue" | . style="single")' sample.yml
|
||||
yq eval 'with(.a.deeply.nested; . = "newValue" | . style="single")' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
@ -28,7 +28,7 @@ a:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq eval 'with(.a.deeply ; .nested = "newValue" | .other= "newThing")' sample.yml
|
||||
yq eval 'with(.a.deeply; .nested = "newValue" | .other= "newThing")' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
@ -47,7 +47,7 @@ myArray:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq eval 'with(.myArray[] ; .b = .a + " yum")' sample.yml
|
||||
yq eval 'with(.myArray[]; .b = .a + " yum")' sample.yml
|
||||
```
|
||||
will output
|
||||
```yaml
|
||||
|
@ -15,6 +15,11 @@ var pathTests = []struct {
|
||||
expectedTokens []interface{}
|
||||
expectedPostFix []interface{}
|
||||
}{
|
||||
{
|
||||
"with(.a;.=3)",
|
||||
append(make([]interface{}, 0), "WITH", "(", "a", "BLOCK", "SELF", "ASSIGN", "3 (int64)", ")"),
|
||||
append(make([]interface{}, 0), "a", "SELF", "3 (int64)", "ASSIGN", "BLOCK", "WITH"),
|
||||
},
|
||||
{
|
||||
"0x12",
|
||||
append(make([]interface{}, 0), "18 (int64)"),
|
||||
|
@ -340,7 +340,7 @@ func initLexer() (*lex.Lexer, error) {
|
||||
lexer.Add([]byte("( |\t|\n|\r)+"), skip)
|
||||
|
||||
lexer.Add([]byte(`\."[^ "]+"\??`), pathToken(true))
|
||||
lexer.Add([]byte(`\.[^ \}\{\:\[\],\|\.\[\(\)=\n]+\??`), pathToken(false))
|
||||
lexer.Add([]byte(`\.[^ ;\}\{\:\[\],\|\.\[\(\)=\n]+\??`), pathToken(false))
|
||||
lexer.Add([]byte(`\.`), selfToken())
|
||||
|
||||
lexer.Add([]byte(`\|`), opToken(pipeOpType))
|
||||
|
@ -6,7 +6,7 @@ var withOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
description: "Update and style",
|
||||
document: `a: {deeply: {nested: value}}`,
|
||||
expression: `with(.a.deeply.nested ; . = "newValue" | . style="single")`,
|
||||
expression: `with(.a.deeply.nested; . = "newValue" | . style="single")`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::a: {deeply: {nested: 'newValue'}}\n",
|
||||
},
|
||||
@ -14,7 +14,7 @@ var withOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
description: "Update multiple deeply nested properties",
|
||||
document: `a: {deeply: {nested: value, other: thing}}`,
|
||||
expression: `with(.a.deeply ; .nested = "newValue" | .other= "newThing")`,
|
||||
expression: `with(.a.deeply; .nested = "newValue" | .other= "newThing")`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::a: {deeply: {nested: newValue, other: newThing}}\n",
|
||||
},
|
||||
@ -22,7 +22,7 @@ var withOperatorScenarios = []expressionScenario{
|
||||
{
|
||||
description: "Update array elements relatively",
|
||||
document: `myArray: [{a: apple},{a: banana}]`,
|
||||
expression: `with(.myArray[] ; .b = .a + " yum")`,
|
||||
expression: `with(.myArray[]; .b = .a + " yum")`,
|
||||
expected: []string{
|
||||
"D0, P[], (doc)::myArray: [{a: apple, b: apple yum}, {a: banana, b: banana yum}]\n",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user