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

Updated docs to include value parsing

This commit is contained in:
Mike Farah
2020-01-20 08:35:03 +11:00
parent b7148adf20
commit 8a65822b0b
16 changed files with 1502 additions and 555 deletions

View File

@@ -94,7 +94,7 @@
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" data-md-component="overlay" for="__drawer"></label>
<a href="#to-stdout" tabindex="1" class="md-skip">
<a href="#merge-example" tabindex="1" class="md-skip">
Skip to content
</a>
@@ -241,8 +241,8 @@
<li class="md-nav__item">
<a href="../read/" title="Read" class="md-nav__link">
Read
<a href="../path_expressions/" title="Path Expressions" class="md-nav__link">
Path Expressions
</a>
</li>
@@ -253,8 +253,20 @@
<li class="md-nav__item">
<a href="../path_expressions/" title="Path Expressions" class="md-nav__link">
Path Expressions
<a href="../value_parsing/" title="Value Parsing" class="md-nav__link">
Value Parsing
</a>
</li>
<li class="md-nav__item">
<a href="../read/" title="Read" class="md-nav__link">
Read
</a>
</li>
@@ -348,8 +360,8 @@
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
To Stdout
<a href="#merge-example" title="Merge example" class="md-nav__link">
Merge example
</a>
</li>
@@ -366,13 +378,19 @@
Overwrite values
</a>
</li>
<li class="md-nav__item">
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#overwrite-values-with-arrays" title="Overwrite values with arrays" class="md-nav__link">
Overwrite values with arrays
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
@@ -383,18 +401,31 @@
</li>
<li class="md-nav__item">
<a href="#multiple-documents-merge-into-single-document" title="Multiple Documents - merge into single document" class="md-nav__link">
Multiple Documents - merge into single document
<a href="#multiple-documents" title="Multiple Documents" class="md-nav__link">
Multiple Documents
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#merge-into-single-document" title="Merge into single document" class="md-nav__link">
Merge into single document
</a>
</li>
<li class="md-nav__item">
<a href="#multiple-documents-merge-into-all-documents" title="Multiple Documents - merge into all documents" class="md-nav__link">
Multiple Documents - merge into all documents
<li class="md-nav__item">
<a href="#merge-into-all-documents" title="Merge into all documents" class="md-nav__link">
Merge into all documents
</a>
</li>
</ul>
</nav>
</li>
@@ -426,8 +457,8 @@
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#to-stdout" title="To Stdout" class="md-nav__link">
To Stdout
<a href="#merge-example" title="Merge example" class="md-nav__link">
Merge example
</a>
</li>
@@ -444,13 +475,19 @@
Overwrite values
</a>
</li>
<li class="md-nav__item">
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#overwrite-values-with-arrays" title="Overwrite values with arrays" class="md-nav__link">
Overwrite values with arrays
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
@@ -461,18 +498,31 @@
</li>
<li class="md-nav__item">
<a href="#multiple-documents-merge-into-single-document" title="Multiple Documents - merge into single document" class="md-nav__link">
Multiple Documents - merge into single document
<a href="#multiple-documents" title="Multiple Documents" class="md-nav__link">
Multiple Documents
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#merge-into-single-document" title="Merge into single document" class="md-nav__link">
Merge into single document
</a>
</li>
<li class="md-nav__item">
<a href="#multiple-documents-merge-into-all-documents" title="Multiple Documents - merge into all documents" class="md-nav__link">
Multiple Documents - merge into all documents
<li class="md-nav__item">
<a href="#merge-into-all-documents" title="Merge into all documents" class="md-nav__link">
Merge into all documents
</a>
</li>
</ul>
</nav>
</li>
@@ -500,7 +550,7 @@ set values for any key not existing already or where the key has no value.</p>
<pre><code>yq m &lt;yaml_file&gt; &lt;path&gt;...
</code></pre>
<h3 id="to-stdout">To Stdout<a class="headerlink" href="#to-stdout" title="Permanent link">&para;</a></h3>
<h2 id="merge-example">Merge example<a class="headerlink" href="#merge-example" title="Permanent link">&para;</a></h2>
<p>Given a data1.yaml file of:</p>
<pre><code class="yaml">a: simple
b: [1, 2]
@@ -523,24 +573,12 @@ c:
test: 1
</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 data1.yaml file of:</p>
<pre><code class="yaml">a: simple
b: [1, 2]
</code></pre>
<p>and data2.yaml file of:</p>
<pre><code class="yaml">a: other
c:
test: 1
</code></pre>
<p>then</p>
<h2 id="updating-files-in-place">Updating files in-place<a class="headerlink" href="#updating-files-in-place" title="Permanent link">&para;</a></h2>
<pre><code class="bash">yq m -i data1.yaml data2.yaml
</code></pre>
<p>will update the data1.yaml file so that the value of 'c' is 'test: 1'.</p>
<h3 id="overwrite-values">Overwrite values<a class="headerlink" href="#overwrite-values" title="Permanent link">&para;</a></h3>
<p>will update the data1.yaml file with the merged result.</p>
<h2 id="overwrite-values">Overwrite values<a class="headerlink" href="#overwrite-values" title="Permanent link">&para;</a></h2>
<p>Given a data1.yaml file of:</p>
<pre><code class="yaml">a: simple
b: [1, 2]
@@ -591,7 +629,7 @@ d: false
</code></pre>
<p>Notice that 'b' does not result in the merging of the values within an array. </p>
<h3 id="append-values-with-arrays">Append values with arrays<a class="headerlink" href="#append-values-with-arrays" title="Permanent link">&para;</a></h3>
<h2 id="append-values-with-arrays">Append values with arrays<a class="headerlink" href="#append-values-with-arrays" title="Permanent link">&para;</a></h2>
<p>Given a data1.yaml file of:</p>
<pre><code class="yaml">a: simple
b: [1, 2]
@@ -620,7 +658,8 @@ d: hi
</code></pre>
<p>Note that the 'b' array has concatenated the values from the second data file. Also note that other map keys are not overridden (field a).</p>
<h3 id="multiple-documents-merge-into-single-document">Multiple Documents - merge into single document<a class="headerlink" href="#multiple-documents-merge-into-single-document" title="Permanent link">&para;</a></h3>
<h2 id="multiple-documents">Multiple Documents<a class="headerlink" href="#multiple-documents" title="Permanent link">&para;</a></h2>
<h3 id="merge-into-single-document">Merge into single document<a class="headerlink" href="#merge-into-single-document" title="Permanent link">&para;</a></h3>
<p>Currently yq only has multi-document support for the <em>first</em> document being merged into. The remaining yaml files will have their first document selected.</p>
<p>Given a data1.yaml file of:</p>
<pre><code class="yaml">something: else
@@ -644,7 +683,7 @@ a: simple
b: dog
</code></pre>
<h3 id="multiple-documents-merge-into-all-documents">Multiple Documents - merge into all documents<a class="headerlink" href="#multiple-documents-merge-into-all-documents" title="Permanent link">&para;</a></h3>
<h3 id="merge-into-all-documents">Merge into all documents<a class="headerlink" href="#merge-into-all-documents" title="Permanent link">&para;</a></h3>
<p>Currently yq only has multi-document support for the <em>first</em> document being merged into. The remaining yaml files will have their first document selected.</p>
<p>Given a data1.yaml file of:</p>
<pre><code class="yaml">something: else