1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Feature: Add append to array

Adds the ability to append a value to an array instead of having to
know the index of the values within the array.

Resolves: #17
This commit is contained in:
kenjones
2017-09-23 20:21:16 -04:00
parent c17f8df8f8
commit c5f80a105d
8 changed files with 103 additions and 9 deletions

View File

@@ -250,6 +250,13 @@
Adding new fields
</a>
</li>
<li class="md-nav__item">
<a href="#appending-value-to-an-array-field" title="Appending value to an array field" class="md-nav__link">
Appending value to an array field
</a>
</li>
<li class="md-nav__item">
@@ -355,6 +362,13 @@
Adding new fields
</a>
</li>
<li class="md-nav__item">
<a href="#appending-value-to-an-array-field" title="Appending value to an array field" class="md-nav__link">
Appending value to an array field
</a>
</li>
<li class="md-nav__item">
@@ -436,6 +450,28 @@
- new thing
</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:
c: 2
d:
- new thing
- foo thing
</code></pre>
<p>then</p>
<pre><code class="bash">yaml w sample.yaml b.d[+] &quot;bar thing&quot;
</code></pre>
<p>will output:</p>
<pre><code class="yaml">b:
c: cat
d:
- new thing
- foo thing
- bar thing
</code></pre>
<h3 id="updating-files-in-place">Updating files in-place<a class="headerlink" href="#updating-files-in-place" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">b: