diff --git a/docs/convert/index.html b/docs/convert/index.html index 20d4de9..463def4 100644 --- a/docs/convert/index.html +++ b/docs/convert/index.html @@ -323,7 +323,7 @@

Convert

-

Yaml to Json

+

Yaml to Json

To convert output to json, use the --tojson (or -j) flag. This can be used with any command.

Given a sample.yaml file of:

b:
@@ -338,7 +338,7 @@
 
{"b":{"c":2}}
 
-

Json to Yaml

+

Json to Yaml

To read in json, just pass in a json file instead of yaml, it will just work :)

e.g given a json file

{"a":"Easy! as one two three","b":{"c":2,"d":[3,4]}}
diff --git a/docs/create/index.html b/docs/create/index.html
index 22bab67..ccc3f8d 100644
--- a/docs/create/index.html
+++ b/docs/create/index.html
@@ -327,7 +327,7 @@
 
yaml n <path> <new value>
 
-

Creating a simple yaml file

+

Creating a simple yaml file

yaml n b.c cat
 
@@ -336,7 +336,7 @@ c: cat
-

Creating using a create script

+

Creating using a create script

Create scripts follow the same format as the update scripts.

Given a script create_instructions.yaml of:

b.c: 3
diff --git a/docs/index.html b/docs/index.html
index 9469506..e5df1c1 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -327,11 +327,11 @@
               
                 
                 
-                

yaml

+

yaml

yaml is a lightweight and portable command-line YAML processor

The aim of the project is to be the jq or sed of yaml files.

-

download latest binary

-

get the source

+

download latest binary

+

get the source

go get github.com/mikefarah/yaml
 
diff --git a/docs/mkdocs/search_index.json b/docs/mkdocs/search_index.json index 26a2c5c..ac2528c 100644 --- a/docs/mkdocs/search_index.json +++ b/docs/mkdocs/search_index.json @@ -57,7 +57,7 @@ }, { "location": "/write/", - "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", + "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", "title": "Write/Update" }, { @@ -85,6 +85,11 @@ "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", "title": "Updating multiple values with a script" }, + { + "location": "/write/#values-starting-with-a-hyphen-or-dash", + "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", + "title": "Values starting with a hyphen (or dash)" + }, { "location": "/create/", "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 -", diff --git a/docs/read/index.html b/docs/read/index.html index 4e0e799..feb2cb1 100644 --- a/docs/read/index.html +++ b/docs/read/index.html @@ -383,7 +383,7 @@

This command can take a json file as input too, and will output yaml unless specified to export as json (-j)

-

Basic

+

Basic

Given a sample.yaml file of:

b:
   c: 2
@@ -394,13 +394,13 @@
 

will output the value of '2'.

-

From Stdin

+

From Stdin

Given a sample.yaml file of:

cat sample.yaml | yaml r - b.c
 

will output the value of '2'.

-

Splat

+

Splat

Given a sample.yaml file of:

---
 bob:
@@ -419,7 +419,7 @@ bob:
 - apples
 
-

Handling '.' in the yaml key

+

Handling '.' in the yaml key

Given a sample.yaml file of:

b.x:
   c: 2
@@ -430,7 +430,7 @@ bob:
 

will output the value of '2'.

-

Arrays

+

Arrays

You can give an index to access a specific element: e.g.: given a sample file of

b:
@@ -446,7 +446,7 @@ e.g.: given a sample file of

will output 'sam'

-

Array Splat

+

Array Splat

e.g.: given a sample file of

b:
   e:
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index d62befd..c285c2a 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -4,7 +4,7 @@
     
     
      /
-     2017-04-19
+     2017-05-03
      daily
     
     
@@ -12,7 +12,7 @@
     
     
      /read/
-     2017-04-19
+     2017-05-03
      daily
     
     
@@ -20,7 +20,7 @@
     
     
      /write/
-     2017-04-19
+     2017-05-03
      daily
     
     
@@ -28,7 +28,7 @@
     
     
      /create/
-     2017-04-19
+     2017-05-03
      daily
     
     
@@ -36,7 +36,7 @@
     
     
      /convert/
-     2017-04-19
+     2017-05-03
      daily
     
     
diff --git a/docs/write/index.html b/docs/write/index.html
index 1d573c8..c8caaec 100644
--- a/docs/write/index.html
+++ b/docs/write/index.html
@@ -262,6 +262,13 @@
   
 
       
+        
  • + + Values starting with a hyphen (or dash) + + +
  • + @@ -348,6 +355,13 @@ +
  • + + Values starting with a hyphen (or dash) + + +
  • + @@ -369,7 +383,7 @@

    This command can take a json file as input too, and will output yaml unless specified to export as json (-j)

    -

    To Stdout

    +

    To Stdout

    Given a sample.yaml file of:

    b:
       c: 2
    @@ -384,11 +398,11 @@
       c: cat
     
    -

    From STDIN

    +

    From STDIN

    cat sample.yaml | yaml w - b.c blah
     
    -

    Adding new fields

    +

    Adding new fields

    Any missing fields in the path will be created on the fly.

    Given a sample.yaml file of:

    b:
    @@ -406,7 +420,7 @@
         - new thing
     
    -

    Updating files in-place

    +

    Updating files in-place

    Given a sample.yaml file of:

    b:
       c: 2
    @@ -417,7 +431,7 @@
     

    will update the sample.yaml file so that the value of 'c' is cat.

    -

    Updating multiple values with a script

    +

    Updating multiple values with a script

    Given a sample.yaml file of:

    b:
       c: 2
    @@ -444,6 +458,16 @@ b.e[0].name: Howdy Partner
     

    And, of course, you can pipe the instructions in using '-':

    cat update_instructions.yaml | yaml w -s - sample.yaml
     
    + +

    Values starting with a hyphen (or dash)

    +

    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:
    +  path: -Dvalue
    +
    diff --git a/mkdocs/write.md b/mkdocs/write.md index 4d51c1d..f25d8f3 100644 --- a/mkdocs/write.md +++ b/mkdocs/write.md @@ -86,4 +86,17 @@ b: And, of course, you can pipe the instructions in using '-': ```bash cat update_instructions.yaml | yaml w -s - sample.yaml -``` \ No newline at end of file +``` + +### Values starting with a hyphen (or dash) +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 +```yaml +my: + path: -Dvalue +```