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

wip update docs

This commit is contained in:
Mike Farah
2020-01-13 16:58:11 +11:00
parent 350a8343e9
commit 2d7be26ad5
30 changed files with 1401 additions and 1749 deletions

View File

@@ -251,6 +251,18 @@
<li class="md-nav__item">
<a href="../path_expressions/" title="Path Expressions" class="md-nav__link">
Path Expressions
</a>
</li>
@@ -359,20 +371,6 @@
</li>
<li class="md-nav__item">
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
Keys with dots
</a>
</li>
<li class="md-nav__item">
<a href="#keys-and-values-with-leading-dashes" title="Keys (and values) with leading dashes" class="md-nav__link">
Keys (and values) with leading dashes
</a>
</li>
@@ -546,20 +544,6 @@
</li>
<li class="md-nav__item">
<a href="#keys-with-dots" title="Keys with dots" class="md-nav__link">
Keys with dots
</a>
</li>
<li class="md-nav__item">
<a href="#keys-and-values-with-leading-dashes" title="Keys (and values) with leading dashes" class="md-nav__link">
Keys (and values) with leading dashes
</a>
</li>
@@ -581,9 +565,11 @@
<h1>Write/Update</h1>
<pre><code>yq w &lt;yaml_file&gt; &lt;path&gt; &lt;new value&gt;
<pre><code>yq w &lt;yaml_file&gt; &lt;path_expression&gt; &lt;new value&gt;
</code></pre>
<p>Updates all the matching nodes of path expression to the supplied value.</p>
<p>See docs for <a href="../path_expressions/">path expression</a> for more details.</p>
<h3 id="to-stdout">To Stdout<a class="headerlink" href="#to-stdout" title="Permanent link">&para;</a></h3>
<p>Given a sample.yaml file of:</p>
<pre><code class="yaml">b:
@@ -808,30 +794,6 @@ b.e[+].name: Howdy Partner
<pre><code class="yaml">my:
path: -3
</code></pre>
<h3 id="keys-with-dots">Keys with dots<a class="headerlink" href="#keys-with-dots" title="Permanent link">&para;</a></h3>
<p>When specifying a key that has a dot use key lookup indicator.</p>
<pre><code class="yaml">b:
foo.bar: 7
</code></pre>
<pre><code class="bash">yaml r sample.yaml 'b[foo.bar]'
</code></pre>
<pre><code class="bash">yaml w sample.yaml 'b[foo.bar]' 9
</code></pre>
<p>Any valid yaml key can be specified as part of a key lookup.</p>
<p>Note that the path is in quotes to avoid the square brackets being interpreted by your shell.</p>
<h3 id="keys-and-values-with-leading-dashes">Keys (and values) with leading dashes<a class="headerlink" href="#keys-and-values-with-leading-dashes" title="Permanent link">&para;</a></h3>
<p>If a key or value has leading dashes, yq won't know that you are passing a value as opposed to a flag (and you will get a 'bad flag syntax' error).</p>
<p>To fix that, you will need to tell it to stop processing flags by adding '--' after the last flag like so:</p>
<pre><code class="bash">yq n -t -- --key --value
</code></pre>
<p>Will result in</p>
<p><code>`
--key: --value</code></p>
@@ -852,7 +814,7 @@ b.e[+].name: Howdy Partner
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../read/" title="Read" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<a href="../path_expressions/" title="Path Expressions" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
@@ -861,7 +823,7 @@ b.e[+].name: Howdy Partner
<span class="md-footer-nav__direction">
Previous
</span>
Read
Path Expressions
</span>
</div>
</a>