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:
@@ -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">¶</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[+] "bar thing"
|
||||
</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">¶</a></h3>
|
||||
<p>Given a sample.yaml file of:</p>
|
||||
<pre><code class="yaml">b:
|
||||
|
||||
Reference in New Issue
Block a user