From a3f8f9df10f46076dc5e02f556183c9ff1dc92b3 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sat, 11 Jan 2020 19:38:16 +1100 Subject: [PATCH] more bits --- commands_test.go | 12 ++++++++++++ yq.go | 3 +++ 2 files changed, 15 insertions(+) diff --git a/commands_test.go b/commands_test.go index d7cebec..bacc496 100644 --- a/commands_test.go +++ b/commands_test.go @@ -103,6 +103,18 @@ func TestReadWithAdvancedFilterCmd(t *testing.T) { test.AssertResult(t, "4", result.Output) } +func TestReadWithAdvancedFilterMapCmd(t *testing.T) { + cmd := getRootCommand() + result := test.RunCmd(cmd, "read -v examples/sample.yaml b.e[name==fred]") + if result.Error != nil { + t.Error(result.Error) + } + expectedOutput := `name: fred +value: 3 +` + test.AssertResult(t, expectedOutput, result.Output) +} + func TestReadWithKeyAndValueCmd(t *testing.T) { cmd := getRootCommand() result := test.RunCmd(cmd, "read -p pv examples/sample.yaml b.c") diff --git a/yq.go b/yq.go index 931be12..2a82175 100644 --- a/yq.go +++ b/yq.go @@ -100,6 +100,7 @@ yq read things.yaml a.b.c yq r - a.b.c (reads from stdin) yq r things.yaml a.*.c yq r things.yaml a.**.c +yq r things.yaml a.(child.subchild==cool).c yq r -d1 things.yaml 'a.array[0].blah' yq r things.yaml 'a.array[*].blah' yq r -- things.yaml --key-starting-with-dashes.blah @@ -121,6 +122,7 @@ func createWriteCmd() *cobra.Command { yq write things.yaml a.b.c true yq write things.yaml 'a.*.c' true yq write things.yaml 'a.**' true +yq write things.yaml a.(child.subchild==cool).c true yq write things.yaml a.b.c --tag '!!str' true yq write things.yaml a.b.c --tag '!!float' 3 yq write --inplace -- things.yaml a.b.c --cat @@ -187,6 +189,7 @@ func createDeleteCmd() *cobra.Command { Example: ` yq delete things.yaml a.b.c yq delete things.yaml a.*.c +yq delete things.yaml a.(child.subchild==cool).c yq delete things.yaml a.** yq delete --inplace things.yaml a.b.c yq delete --inplace -- things.yaml --key-starting-with-dash