From e5bcfedbe9fb28a42151df5a0e20c6608889285c Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 13 May 2019 17:50:08 +1000 Subject: [PATCH] updating docs --- mkdocs/read.md | 25 ++++++++++++++++++++++ mkdocs/write.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/mkdocs/read.md b/mkdocs/read.md index ad842206..ca526993 100644 --- a/mkdocs/read.md +++ b/mkdocs/read.md @@ -32,6 +32,8 @@ bob: cats: bananas item2: cats: apples + thing: + cats: oranges ``` then ```bash @@ -41,6 +43,29 @@ will output ```yaml - bananas - apples +- oranges +``` + +### Prefix Splat +Given a sample.yaml file of: +```yaml +--- +bob: + item1: + cats: bananas + item2: + cats: apples + thing: + cats: oranges +``` +then +```bash +yq r sample.yaml bob.item*.cats +``` +will output +```yaml +- bananas +- apples ``` ### Multiple Documents - specify a single document diff --git a/mkdocs/write.md b/mkdocs/write.md index fd8dbbcb..d06feaa2 100644 --- a/mkdocs/write.md +++ b/mkdocs/write.md @@ -43,6 +43,62 @@ b: - new thing ``` +### Splat +Given a sample.yaml file of: +```yaml +--- +bob: + item1: + cats: bananas + item2: + cats: apples + thing: + cats: oranges +``` +then +```bash +yq w sample.yaml bob.*.cats meow +``` +will output: +```yaml +--- +bob: + item1: + cats: meow + item2: + cats: meow + thing: + cats: meow +``` + +### Prefix Splat +Given a sample.yaml file of: +```yaml +--- +bob: + item1: + cats: bananas + item2: + cats: apples + thing: + cats: oranges +``` +then +```bash +yq w sample.yaml bob.item*.cats meow +``` +will output: +```yaml +--- +bob: + item1: + cats: meow + item2: + cats: meow + thing: + cats: oranges +``` + ### Appending value to an array field Given a sample.yaml file of: ```yaml