From 38d35185bc09d0046cf440ab380511cda79d8b77 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 6 Jan 2020 16:27:00 +1300 Subject: [PATCH] Can overwrite and append with merge --- commands_test.go | 15 +++++++++++++++ yq.go | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/commands_test.go b/commands_test.go index c310d59e..9f600f38 100644 --- a/commands_test.go +++ b/commands_test.go @@ -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") diff --git a/yq.go b/yq.go index adfd05f6..053b4a98 100644 --- a/yq.go +++ b/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, }