Updated instructions

This commit is contained in:
Mike Farah 2019-05-14 16:05:25 +10:00
parent e5bcfedbe9
commit 0f8b864321
6 changed files with 396 additions and 1 deletions

View File

@ -325,6 +325,27 @@
Deleting nodes in-place
</a>
</li>
<li class="md-nav__item">
<a href="#splat" title="Splat" class="md-nav__link">
Splat
</a>
</li>
<li class="md-nav__item">
<a href="#prefix-splat" title="Prefix Splat" class="md-nav__link">
Prefix Splat
</a>
</li>
<li class="md-nav__item">
<a href="#array-splat" title="Array Splat" class="md-nav__link">
Array Splat
</a>
</li>
<li class="md-nav__item">
@ -446,6 +467,27 @@
Deleting nodes in-place
</a>
</li>
<li class="md-nav__item">
<a href="#splat" title="Splat" class="md-nav__link">
Splat
</a>
</li>
<li class="md-nav__item">
<a href="#prefix-splat" title="Prefix Splat" class="md-nav__link">
Prefix Splat
</a>
</li>
<li class="md-nav__item">
<a href="#array-splat" title="Array Splat" class="md-nav__link">
Array Splat
</a>
</li>
<li class="md-nav__item">
@ -552,6 +594,91 @@
</code></pre>
<p>will update the sample.yaml file so that the 'c' node is deleted</p>
<h3 id="splat">Splat<a class="headerlink" href="#splat" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">---
bob:
item1:
cats: bananas
dogs: woof
item2:
cats: apples
dogs: woof2
thing:
cats: oranges
dogs: woof3
</code></pre>
<p>then</p>
<pre><code class="bash">yq d sample.yaml bob.*.cats
</code></pre>
<p>will output:</p>
<pre><code class="yaml">---
bob:
item1:
dogs: woof
item2:
dogs: woof2
thing:
dogs: woof3
</code></pre>
<h3 id="prefix-splat">Prefix Splat<a class="headerlink" href="#prefix-splat" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">---
bob:
item1:
cats: bananas
dogs: woof
item2:
cats: apples
dogs: woof2
thing:
cats: oranges
dogs: woof3
</code></pre>
<p>then</p>
<pre><code class="bash">yq d sample.yaml bob.item*.cats
</code></pre>
<p>will output:</p>
<pre><code class="yaml">---
bob:
item1:
dogs: woof
item2:
dogs: woof2
thing:
cats: oranges
dogs: woof3
</code></pre>
<h3 id="array-splat">Array Splat<a class="headerlink" href="#array-splat" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">---
bob:
- cats: bananas
dogs: woof
- cats: apples
dogs: woof2
- cats: oranges
dogs: woof3
</code></pre>
<p>then</p>
<pre><code class="bash">yq d sample.yaml bob.[*].cats
</code></pre>
<p>will output:</p>
<pre><code class="yaml">---
bob:
- dogs: woof
- dogs: woof2
- dogs: woof3
</code></pre>
<h3 id="multiple-documents-delete-from-single-document">Multiple Documents - delete from single document<a class="headerlink" href="#multiple-documents-delete-from-single-document" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">something: else

View File

@ -282,6 +282,13 @@
Splat
</a>
</li>
<li class="md-nav__item">
<a href="#prefix-splat" title="Prefix Splat" class="md-nav__link">
Prefix Splat
</a>
</li>
<li class="md-nav__item">
@ -446,6 +453,13 @@
Splat
</a>
</li>
<li class="md-nav__item">
<a href="#prefix-splat" title="Prefix Splat" class="md-nav__link">
Prefix Splat
</a>
</li>
<li class="md-nav__item">
@ -540,12 +554,36 @@ bob:
cats: bananas
item2:
cats: apples
thing:
cats: oranges
</code></pre>
<p>then</p>
<pre><code class="bash">yq r sample.yaml bob.*.cats
</code></pre>
<p>will output</p>
<pre><code class="yaml">- bananas
- apples
- oranges
</code></pre>
<h3 id="prefix-splat">Prefix Splat<a class="headerlink" href="#prefix-splat" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">---
bob:
item1:
cats: bananas
item2:
cats: apples
thing:
cats: oranges
</code></pre>
<p>then</p>
<pre><code class="bash">yq r sample.yaml bob.item*.cats
</code></pre>
<p>will output</p>
<pre><code class="yaml">- bananas
- apples

File diff suppressed because one or more lines are too long

View File

@ -294,6 +294,27 @@
Adding new fields
</a>
</li>
<li class="md-nav__item">
<a href="#splat" title="Splat" class="md-nav__link">
Splat
</a>
</li>
<li class="md-nav__item">
<a href="#prefix-splat" title="Prefix Splat" class="md-nav__link">
Prefix Splat
</a>
</li>
<li class="md-nav__item">
<a href="#array-splat" title="Array Splat" class="md-nav__link">
Array Splat
</a>
</li>
<li class="md-nav__item">
@ -460,6 +481,27 @@
Adding new fields
</a>
</li>
<li class="md-nav__item">
<a href="#splat" title="Splat" class="md-nav__link">
Splat
</a>
</li>
<li class="md-nav__item">
<a href="#prefix-splat" title="Prefix Splat" class="md-nav__link">
Prefix Splat
</a>
</li>
<li class="md-nav__item">
<a href="#array-splat" title="Array Splat" class="md-nav__link">
Array Splat
</a>
</li>
<li class="md-nav__item">
@ -579,6 +621,81 @@
- new thing
</code></pre>
<h3 id="splat">Splat<a class="headerlink" href="#splat" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">---
bob:
item1:
cats: bananas
item2:
cats: apples
thing:
cats: oranges
</code></pre>
<p>then</p>
<pre><code class="bash">yq w sample.yaml bob.*.cats meow
</code></pre>
<p>will output:</p>
<pre><code class="yaml">---
bob:
item1:
cats: meow
item2:
cats: meow
thing:
cats: meow
</code></pre>
<h3 id="prefix-splat">Prefix Splat<a class="headerlink" href="#prefix-splat" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">---
bob:
item1:
cats: bananas
item2:
cats: apples
thing:
cats: oranges
</code></pre>
<p>then</p>
<pre><code class="bash">yq w sample.yaml bob.item*.cats meow
</code></pre>
<p>will output:</p>
<pre><code class="yaml">---
bob:
item1:
cats: meow
item2:
cats: meow
thing:
cats: oranges
</code></pre>
<h3 id="array-splat">Array Splat<a class="headerlink" href="#array-splat" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">---
bob:
- cats: bananas
- cats: apples
- cats: oranges
</code></pre>
<p>then</p>
<pre><code class="bash">yq w sample.yaml bob[*].cats meow
</code></pre>
<p>will output:</p>
<pre><code class="yaml">---
bob:
- cats: meow
- cats: meow
- cats: meow
</code></pre>
<h3 id="appending-value-to-an-array-field">Appending value to an array field<a class="headerlink" href="#appending-value-to-an-array-field" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">b:

View File

@ -59,6 +59,93 @@ yq d -i sample.yaml b.c
will update the sample.yaml file so that the 'c' node is deleted
### Splat
Given a sample.yaml file of:
```yaml
---
bob:
item1:
cats: bananas
dogs: woof
item2:
cats: apples
dogs: woof2
thing:
cats: oranges
dogs: woof3
```
then
```bash
yq d sample.yaml bob.*.cats
```
will output:
```yaml
---
bob:
item1:
dogs: woof
item2:
dogs: woof2
thing:
dogs: woof3
```
### Prefix Splat
Given a sample.yaml file of:
```yaml
---
bob:
item1:
cats: bananas
dogs: woof
item2:
cats: apples
dogs: woof2
thing:
cats: oranges
dogs: woof3
```
then
```bash
yq d sample.yaml bob.item*.cats
```
will output:
```yaml
---
bob:
item1:
dogs: woof
item2:
dogs: woof2
thing:
cats: oranges
dogs: woof3
```
### Array Splat
Given a sample.yaml file of:
```yaml
---
bob:
- cats: bananas
dogs: woof
- cats: apples
dogs: woof2
- cats: oranges
dogs: woof3
```
then
```bash
yq d sample.yaml bob.[*].cats
```
will output:
```yaml
---
bob:
- dogs: woof
- dogs: woof2
- dogs: woof3
```
### Multiple Documents - delete from single document
Given a sample.yaml file of:

View File

@ -99,6 +99,28 @@ bob:
cats: oranges
```
### Array Splat
Given a sample.yaml file of:
```yaml
---
bob:
- cats: bananas
- cats: apples
- cats: oranges
```
then
```bash
yq w sample.yaml bob[*].cats meow
```
will output:
```yaml
---
bob:
- cats: meow
- cats: meow
- cats: meow
```
### Appending value to an array field
Given a sample.yaml file of:
```yaml