Skip to content

Commit ab3975c

Browse files
Merge pull request #173 from gabriel-samfira/update-readme
Update README.md
2 parents 00b3579 + 066dade commit ab3975c

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,71 @@ True True Int64 System.ValueType
243243

244244
As you can see, the phone number without tags was cast to ```Int64```. This is most likely not the desired result and a case where tags should be used.
245245

246+
## Controlling output formatting
247+
248+
By default `ConvertTo-Yaml` will output in `Block` style. You can control the output formatting by using `-Options` parameter and specifying one of the following values: `UseFlowStyle` or `UseSequenceFlowStyle`. The `UseFlowStyle` option will output everything in `Flow` style. The `UseSequenceFlowStyle` option will output sequences in `Flow` style and everything else in `Block` style.
249+
250+
Here is an example of using the `UseFlowStyle` option:
251+
252+
```powershell
253+
Import-Module powershell-yaml
254+
255+
PS C:\> $data = @{
256+
"anArray" = @(1, 2, 3)
257+
"nested" = @{
258+
"array" = @("this", "is", "an", "array")
259+
}
260+
"hello" = "world"
261+
}
262+
263+
PS C:\> ConvertTo-Yaml $data -Options UseFlowStyle
264+
{anArray: [1, 2, 3], nested: {array: [this, is, an, array]}, hello: world}
265+
```
266+
267+
Here is an example of using the `UseSequenceFlowStyle` option:
268+
269+
```powershell
270+
PS C:\> ConvertTo-Yaml $data -Options UseSequenceFlowStyle
271+
272+
anArray: [1, 2, 3]
273+
nested:
274+
array: [this, is, an, array]
275+
hello: world
276+
```
277+
278+
There is another tweak you can use. When using the default `Block` style, sequences are not indented. You can toggle this by passing in the `WithIndentedSequences` option.
279+
280+
Here are examples with and without indented sequences:
281+
282+
```powershell
283+
PS C:\> ConvertTo-Yaml $data
284+
anArray:
285+
- 1
286+
- 2
287+
- 3
288+
nested:
289+
array:
290+
- this
291+
- is
292+
- an
293+
- array
294+
hello: world
295+
296+
297+
PS C:\> ConvertTo-Yaml $data -Options WithIndentedSequences
298+
anArray:
299+
- 1
300+
- 2
301+
- 3
302+
nested:
303+
array:
304+
- this
305+
- is
306+
- an
307+
- array
308+
hello: world
309+
```
310+
246311
## Running the tests
247312

248313
Before running the associated unit tests; please make sure you have

0 commit comments

Comments
 (0)