@@ -14,6 +14,9 @@ go get github.com/mikefarah/yaml
14
14
- Deep read a yaml file with a given path
15
15
- Update a yaml file given a path
16
16
- Update a yaml file given a script file
17
+ - Update creates any missing entries in the path on the fly
18
+ - Create a yaml file given a deep path and value
19
+ - Create a yaml file given a script file
17
20
- Convert from json to yaml
18
21
- Convert from yaml to json
19
22
@@ -111,6 +114,7 @@ will output:
111
114
```
112
115
113
116
## Update examples
117
+ Existing yaml files can be updated via the write command
114
118
115
119
### Update to stdout
116
120
Given a sample.yaml file of:
128
132
c : cat
129
133
` ` `
130
134
135
+ ### Adding new fields
136
+ Any missing fields in the path will be created on the fly.
137
+
138
+ Given a sample.yaml file of:
139
+ ` ` ` yaml
140
+ b :
141
+ c : 2
142
+ ` ` `
143
+ then
144
+ ` ` ` bash
145
+ yaml w sample.yaml b.d[0] "new thing"
146
+ ```
147
+ will output:
148
+ ``` yaml
149
+ b :
150
+ c : cat
151
+ d :
152
+ - new thing
153
+ ` ` `
154
+
131
155
### Updating yaml in-place
132
156
Given a sample.yaml file of:
133
157
` ` ` yaml
167
191
- name : Howdy Partner
168
192
` ` `
169
193
194
+ ## New Examples
195
+ 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.
196
+
197
+ ### Creating a simple yaml file
198
+ ` ` ` bash
199
+ yaml n b.c cat
200
+ ```
201
+ will output:
202
+ ``` yaml
203
+ b :
204
+ c : cat
205
+ ` ` `
206
+
207
+ ### Creating using a create script
208
+ Create scripts follow the same format as the update scripts.
209
+
210
+ Given a script create_instructions.yaml of:
211
+ ` ` ` yaml
212
+ b.c : 3
213
+ b.e[0].name : Howdy Partner
214
+ ` ` `
215
+ then
216
+
217
+ ` ` ` bash
218
+ yaml n -s create_instructions.yaml
219
+ ```
220
+ will output:
221
+ ``` yaml
222
+ b :
223
+ c : 3
224
+ e :
225
+ - name : Howdy Partner
226
+ ` ` `
227
+
170
228
## Converting to and from json
171
229
172
230
### Yaml2json
0 commit comments