mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Can overwrite and append with merge
This commit is contained in:
parent
d8c29b26c1
commit
38d35185bc
@ -1337,6 +1337,21 @@ c:
|
||||
`
|
||||
test.AssertResult(t, expectedOutput, result.Output)
|
||||
}
|
||||
|
||||
func TestMergeOverwriteAndAppendCmd(t *testing.T) {
|
||||
cmd := getRootCommand()
|
||||
result := test.RunCmd(cmd, "merge --autocreate=false --append --overwrite examples/data1.yaml examples/data2.yaml")
|
||||
if result.Error != nil {
|
||||
t.Error(result.Error)
|
||||
}
|
||||
expectedOutput := `a: other # better than the original
|
||||
b: [1, 2, 3, 4]
|
||||
c:
|
||||
test: 1
|
||||
`
|
||||
test.AssertResult(t, expectedOutput, result.Output)
|
||||
}
|
||||
|
||||
func TestMergeArraysCmd(t *testing.T) {
|
||||
cmd := getRootCommand()
|
||||
result := test.RunCmd(cmd, "merge --append examples/sample_array.yaml examples/sample_array_2.yaml")
|
||||
|
2
yq.go
2
yq.go
@ -231,8 +231,6 @@ Outputs to STDOUT unless the inplace flag is used, in which case the file is upd
|
||||
|
||||
If overwrite flag is set then existing values will be overwritten using the values from each additional yaml file.
|
||||
If append flag is set then existing arrays will be merged with the arrays from each additional yaml file.
|
||||
|
||||
Note that if you set both flags only overwrite will take effect.
|
||||
`,
|
||||
RunE: mergeProperties,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user