Skip to content

Commit 69e6bb3

Browse files
author
Mike Farah
committed
Added doco regarding values starting with hyphens
1 parent ec25886 commit 69e6bb3

File tree

8 files changed

+67
-25
lines changed

8 files changed

+67
-25
lines changed

docs/convert/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@
323323

324324
<h1>Convert</h1>
325325

326-
<h3 id="yaml-to-json">Yaml to Json</h3>
326+
<h3 id="yaml-to-json">Yaml to Json<a class="headerlink" href="#yaml-to-json" title="Permanent link">&para;</a></h3>
327327
<p>To convert output to json, use the --tojson (or -j) flag. This can be used with any command.</p>
328328
<p>Given a sample.yaml file of:</p>
329329
<pre><code class="yaml">b:
@@ -338,7 +338,7 @@ <h3 id="yaml-to-json">Yaml to Json</h3>
338338
<pre><code class="json">{&quot;b&quot;:{&quot;c&quot;:2}}
339339
</code></pre>
340340

341-
<h3 id="json-to-yaml">Json to Yaml</h3>
341+
<h3 id="json-to-yaml">Json to Yaml<a class="headerlink" href="#json-to-yaml" title="Permanent link">&para;</a></h3>
342342
<p>To read in json, just pass in a json file instead of yaml, it will just work :)</p>
343343
<p>e.g given a json file</p>
344344
<pre><code class="json">{&quot;a&quot;:&quot;Easy! as one two three&quot;,&quot;b&quot;:{&quot;c&quot;:2,&quot;d&quot;:[3,4]}}

docs/create/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ <h1>Create</h1>
327327
<pre><code>yaml n &lt;path&gt; &lt;new value&gt;
328328
</code></pre>
329329

330-
<h3 id="creating-a-simple-yaml-file">Creating a simple yaml file</h3>
330+
<h3 id="creating-a-simple-yaml-file">Creating a simple yaml file<a class="headerlink" href="#creating-a-simple-yaml-file" title="Permanent link">&para;</a></h3>
331331
<pre><code class="bash">yaml n b.c cat
332332
</code></pre>
333333

@@ -336,7 +336,7 @@ <h3 id="creating-a-simple-yaml-file">Creating a simple yaml file</h3>
336336
c: cat
337337
</code></pre>
338338

339-
<h3 id="creating-using-a-create-script">Creating using a create script</h3>
339+
<h3 id="creating-using-a-create-script">Creating using a create script<a class="headerlink" href="#creating-using-a-create-script" title="Permanent link">&para;</a></h3>
340340
<p>Create scripts follow the same format as the update scripts.</p>
341341
<p>Given a script create_instructions.yaml of:</p>
342342
<pre><code class="yaml">b.c: 3

docs/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@
327327

328328

329329

330-
<h1 id="yaml">yaml</h1>
330+
<h1 id="yaml">yaml<a class="headerlink" href="#yaml" title="Permanent link">&para;</a></h1>
331331
<p>yaml is a lightweight and portable command-line YAML processor</p>
332332
<p>The aim of the project is to be the <a href="https://github.com/stedolan/jq">jq</a> or sed of yaml files.</p>
333-
<h3 id="download-latest-binary"><a href="https://github.com/mikefarah/yaml/releases/latest">download latest binary</a></h3>
334-
<h3 id="get-the-source">get the source</h3>
333+
<h3 id="download-latest-binary"><a href="https://github.com/mikefarah/yaml/releases/latest">download latest binary</a><a class="headerlink" href="#download-latest-binary" title="Permanent link">&para;</a></h3>
334+
<h3 id="get-the-source">get the source<a class="headerlink" href="#get-the-source" title="Permanent link">&para;</a></h3>
335335
<pre><code class="bash">go get github.com/mikefarah/yaml
336336
</code></pre>
337337

docs/mkdocs/search_index.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
},
5858
{
5959
"location": "/write/",
60-
"text": "yaml w \nyaml_file|json_file\n \npath\n \nnew value\n\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nFrom STDIN\n\n\ncat sample.yaml | yaml w - b.c blah\n\n\n\n\nAdding new fields\n\n\nAny missing fields in the path will be created on the fly.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.d[0] \nnew thing\n\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n\n\n\n\nUpdating files in-place\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w -i sample.yaml b.c cat\n\n\n\n\nwill update the sample.yaml file so that the value of 'c' is cat.\n\n\nUpdating multiple values with a script\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n e:\n - name: Billy Bob\n\n\n\n\nand a script update_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyaml w -s update_instructions.yaml sample.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nAnd, of course, you can pipe the instructions in using '-':\n\n\ncat update_instructions.yaml | yaml w -s - sample.yaml",
60+
"text": "yaml w \nyaml_file|json_file\n \npath\n \nnew value\n\n\n\n\n\nThis command can take a json file as input too, and will output yaml unless specified to export as json (-j)\n\n\nTo Stdout\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nFrom STDIN\n\n\ncat sample.yaml | yaml w - b.c blah\n\n\n\n\nAdding new fields\n\n\nAny missing fields in the path will be created on the fly.\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w sample.yaml b.d[0] \nnew thing\n\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n d:\n - new thing\n\n\n\n\nUpdating files in-place\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n\n\n\n\nthen\n\n\nyaml w -i sample.yaml b.c cat\n\n\n\n\nwill update the sample.yaml file so that the value of 'c' is cat.\n\n\nUpdating multiple values with a script\n\n\nGiven a sample.yaml file of:\n\n\nb:\n c: 2\n e:\n - name: Billy Bob\n\n\n\n\nand a script update_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyaml w -s update_instructions.yaml sample.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nAnd, of course, you can pipe the instructions in using '-':\n\n\ncat update_instructions.yaml | yaml w -s - sample.yaml\n\n\n\n\nValues starting with a hyphen (or dash)\n\n\nThis needs a bit of trickery so that it won't try to parse the value as a CLI option. Specifically you will need to wrap the value with a single and double quotes:\n\n\nyaml w my.path '\n-Dvalue\n'\n\n\n\n\nwill output\n\n\nmy:\n path: -Dvalue",
6161
"title": "Write/Update"
6262
},
6363
{
@@ -85,6 +85,11 @@
8585
"text": "Given a sample.yaml file of: b:\n c: 2\n e:\n - name: Billy Bob and a script update_instructions.yaml of: b.c: 3\nb.e[0].name: Howdy Partner then yaml w -s update_instructions.yaml sample.yaml will output: b:\n c: 3\n e:\n - name: Howdy Partner And, of course, you can pipe the instructions in using '-': cat update_instructions.yaml | yaml w -s - sample.yaml",
8686
"title": "Updating multiple values with a script"
8787
},
88+
{
89+
"location": "/write/#values-starting-with-a-hyphen-or-dash",
90+
"text": "This needs a bit of trickery so that it won't try to parse the value as a CLI option. Specifically you will need to wrap the value with a single and double quotes: yaml w my.path ' -Dvalue ' will output my:\n path: -Dvalue",
91+
"title": "Values starting with a hyphen (or dash)"
92+
},
8893
{
8994
"location": "/create/",
9095
"text": "Yaml files can be created using the 'new' command. This works in the same way as the write command, but you don't pass in an existing Yaml file.\n\n\nyaml n \npath\n \nnew value\n\n\n\n\n\nCreating a simple yaml file\n\n\nyaml n b.c cat\n\n\n\n\nwill output:\n\n\nb:\n c: cat\n\n\n\n\nCreating using a create script\n\n\nCreate scripts follow the same format as the update scripts.\n\n\nGiven a script create_instructions.yaml of:\n\n\nb.c: 3\nb.e[0].name: Howdy Partner\n\n\n\n\nthen\n\n\nyaml n -s create_instructions.yaml\n\n\n\n\nwill output:\n\n\nb:\n c: 3\n e:\n - name: Howdy Partner\n\n\n\n\nYou can also pipe the instructions in:\n\n\ncat create_instructions.yaml | yaml n -s -",

docs/read/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ <h1>Read</h1>
383383
</code></pre>
384384

385385
<p>This command can take a json file as input too, and will output yaml unless specified to export as json (-j)</p>
386-
<h3 id="basic">Basic</h3>
386+
<h3 id="basic">Basic<a class="headerlink" href="#basic" title="Permanent link">&para;</a></h3>
387387
<p>Given a sample.yaml file of:</p>
388388
<pre><code class="yaml">b:
389389
c: 2
@@ -394,13 +394,13 @@ <h3 id="basic">Basic</h3>
394394
</code></pre>
395395

396396
<p>will output the value of '2'.</p>
397-
<h3 id="from-stdin">From Stdin</h3>
397+
<h3 id="from-stdin">From Stdin<a class="headerlink" href="#from-stdin" title="Permanent link">&para;</a></h3>
398398
<p>Given a sample.yaml file of:</p>
399399
<pre><code class="bash">cat sample.yaml | yaml r - b.c
400400
</code></pre>
401401

402402
<p>will output the value of '2'.</p>
403-
<h3 id="splat">Splat</h3>
403+
<h3 id="splat">Splat<a class="headerlink" href="#splat" title="Permanent link">&para;</a></h3>
404404
<p>Given a sample.yaml file of:</p>
405405
<pre><code class="yaml">---
406406
bob:
@@ -419,7 +419,7 @@ <h3 id="splat">Splat</h3>
419419
- apples
420420
</code></pre>
421421

422-
<h3 id="handling-in-the-yaml-key">Handling '.' in the yaml key</h3>
422+
<h3 id="handling-in-the-yaml-key">Handling '.' in the yaml key<a class="headerlink" href="#handling-in-the-yaml-key" title="Permanent link">&para;</a></h3>
423423
<p>Given a sample.yaml file of:</p>
424424
<pre><code class="yaml">b.x:
425425
c: 2
@@ -430,7 +430,7 @@ <h3 id="handling-in-the-yaml-key">Handling '.' in the yaml key</h3>
430430
</code></pre>
431431

432432
<p>will output the value of '2'.</p>
433-
<h3 id="arrays">Arrays</h3>
433+
<h3 id="arrays">Arrays<a class="headerlink" href="#arrays" title="Permanent link">&para;</a></h3>
434434
<p>You can give an index to access a specific element:
435435
e.g.: given a sample file of</p>
436436
<pre><code class="yaml">b:
@@ -446,7 +446,7 @@ <h3 id="arrays">Arrays</h3>
446446
</code></pre>
447447

448448
<p>will output 'sam'</p>
449-
<h3 id="array-splat">Array Splat</h3>
449+
<h3 id="array-splat">Array Splat<a class="headerlink" href="#array-splat" title="Permanent link">&para;</a></h3>
450450
<p>e.g.: given a sample file of</p>
451451
<pre><code class="yaml">b:
452452
e:

docs/sitemap.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,39 @@
44

55
<url>
66
<loc>/</loc>
7-
<lastmod>2017-04-19</lastmod>
7+
<lastmod>2017-05-03</lastmod>
88
<changefreq>daily</changefreq>
99
</url>
1010

1111

1212

1313
<url>
1414
<loc>/read/</loc>
15-
<lastmod>2017-04-19</lastmod>
15+
<lastmod>2017-05-03</lastmod>
1616
<changefreq>daily</changefreq>
1717
</url>
1818

1919

2020

2121
<url>
2222
<loc>/write/</loc>
23-
<lastmod>2017-04-19</lastmod>
23+
<lastmod>2017-05-03</lastmod>
2424
<changefreq>daily</changefreq>
2525
</url>
2626

2727

2828

2929
<url>
3030
<loc>/create/</loc>
31-
<lastmod>2017-04-19</lastmod>
31+
<lastmod>2017-05-03</lastmod>
3232
<changefreq>daily</changefreq>
3333
</url>
3434

3535

3636

3737
<url>
3838
<loc>/convert/</loc>
39-
<lastmod>2017-04-19</lastmod>
39+
<lastmod>2017-05-03</lastmod>
4040
<changefreq>daily</changefreq>
4141
</url>
4242

docs/write/index.html

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@
262262

263263
</li>
264264

265+
<li class="md-nav__item">
266+
<a href="#values-starting-with-a-hyphen-or-dash" title="Values starting with a hyphen (or dash)" class="md-nav__link">
267+
Values starting with a hyphen (or dash)
268+
</a>
269+
270+
</li>
271+
265272

266273

267274
</ul>
@@ -348,6 +355,13 @@
348355

349356
</li>
350357

358+
<li class="md-nav__item">
359+
<a href="#values-starting-with-a-hyphen-or-dash" title="Values starting with a hyphen (or dash)" class="md-nav__link">
360+
Values starting with a hyphen (or dash)
361+
</a>
362+
363+
</li>
364+
351365

352366

353367
</ul>
@@ -369,7 +383,7 @@ <h1>Write/Update</h1>
369383
</code></pre>
370384

371385
<p>This command can take a json file as input too, and will output yaml unless specified to export as json (-j)</p>
372-
<h3 id="to-stdout">To Stdout</h3>
386+
<h3 id="to-stdout">To Stdout<a class="headerlink" href="#to-stdout" title="Permanent link">&para;</a></h3>
373387
<p>Given a sample.yaml file of:</p>
374388
<pre><code class="yaml">b:
375389
c: 2
@@ -384,11 +398,11 @@ <h3 id="to-stdout">To Stdout</h3>
384398
c: cat
385399
</code></pre>
386400

387-
<h3 id="from-stdin">From STDIN</h3>
401+
<h3 id="from-stdin">From STDIN<a class="headerlink" href="#from-stdin" title="Permanent link">&para;</a></h3>
388402
<pre><code class="bash">cat sample.yaml | yaml w - b.c blah
389403
</code></pre>
390404

391-
<h3 id="adding-new-fields">Adding new fields</h3>
405+
<h3 id="adding-new-fields">Adding new fields<a class="headerlink" href="#adding-new-fields" title="Permanent link">&para;</a></h3>
392406
<p>Any missing fields in the path will be created on the fly.</p>
393407
<p>Given a sample.yaml file of:</p>
394408
<pre><code class="yaml">b:
@@ -406,7 +420,7 @@ <h3 id="adding-new-fields">Adding new fields</h3>
406420
- new thing
407421
</code></pre>
408422

409-
<h3 id="updating-files-in-place">Updating files in-place</h3>
423+
<h3 id="updating-files-in-place">Updating files in-place<a class="headerlink" href="#updating-files-in-place" title="Permanent link">&para;</a></h3>
410424
<p>Given a sample.yaml file of:</p>
411425
<pre><code class="yaml">b:
412426
c: 2
@@ -417,7 +431,7 @@ <h3 id="updating-files-in-place">Updating files in-place</h3>
417431
</code></pre>
418432

419433
<p>will update the sample.yaml file so that the value of 'c' is cat.</p>
420-
<h3 id="updating-multiple-values-with-a-script">Updating multiple values with a script</h3>
434+
<h3 id="updating-multiple-values-with-a-script">Updating multiple values with a script<a class="headerlink" href="#updating-multiple-values-with-a-script" title="Permanent link">&para;</a></h3>
421435
<p>Given a sample.yaml file of:</p>
422436
<pre><code class="yaml">b:
423437
c: 2
@@ -444,6 +458,16 @@ <h3 id="updating-multiple-values-with-a-script">Updating multiple values with a
444458
<p>And, of course, you can pipe the instructions in using '-':</p>
445459
<pre><code class="bash">cat update_instructions.yaml | yaml w -s - sample.yaml
446460
</code></pre>
461+
462+
<h3 id="values-starting-with-a-hyphen-or-dash">Values starting with a hyphen (or dash)<a class="headerlink" href="#values-starting-with-a-hyphen-or-dash" title="Permanent link">&para;</a></h3>
463+
<p>This needs a bit of trickery so that it won't try to parse the value as a CLI option. Specifically you will need to wrap the value with a single and double quotes:</p>
464+
<pre><code>yaml w my.path '&quot;-Dvalue&quot;'
465+
</code></pre>
466+
467+
<p>will output</p>
468+
<pre><code class="yaml">my:
469+
path: -Dvalue
470+
</code></pre>
447471

448472

449473

mkdocs/write.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,17 @@ b:
8686
And, of course, you can pipe the instructions in using '-':
8787
```bash
8888
cat update_instructions.yaml | yaml w -s - sample.yaml
89-
```
89+
```
90+
91+
### Values starting with a hyphen (or dash)
92+
This needs a bit of trickery so that it won't try to parse the value as a CLI option. Specifically you will need to wrap the value with a single and double quotes:
93+
94+
```
95+
yaml w my.path '"-Dvalue"'
96+
```
97+
98+
will output
99+
```yaml
100+
my:
101+
path: -Dvalue
102+
```

0 commit comments

Comments
 (0)