A command line utility that modifies YAML documents.
Usage
yamlpatch [ option ... ]
-
Parse a YAML document from STDIN, modify it, and print it to STDOUT.
yamlpatch [ option ... ] !yaml-document
-
Parse the literal YAML-document, modify it, and print it to STDOUT.
yamlpatch [ option ] file
-
Transform the YAML document in file in-place.
yamlpatch [ option ] file1 file2
-
Read the YAML document in file1, modify it, and write it to (existing or new) file2.
yamlpatch [ option ] file ... existing-dir
-
Read the YAML document in each file, modify it, and write it to a file in existing-dir.
Options:
General
--help
-
Print this text and terminate.
File processing
--keep
-
For in-place transformations, keep copies of the originals
File transformation
--set [ --existing | --non-existing ] [ --comment ] [ --prepend-map ] spec ( yaml-document | @file-name )
-
Add or change one map entry or sequence element.
- --existing
- Verify that the map entry resp. sequence element already exists
- --non-existing
- Verify that the map entry resp. sequence element does not exist already
- --comment
-
Iff this changes an existing map entry, or an existing sequence element, add an end comment to the map resp.
sequence that displays the original map entry resp. sequence element
- --prepend-map
- Add the new map entry at the beginning (instead of to the end)
--remove [ --existing ] [ --comment ] spec
-
Remove one map entry, sequence element or set member.
- --existing
- Verify that the map entry resp. set member already exists
- --comment
- Add a comment with the removed map entry, sequence element or set member
--insert spec ( yaml-document | @file-name )
-
Insert an element into an sequence.
--add [ --non-existing ] [ --prepend ] spec
-
Add a member to a set.
- --non-existing
- Verify that the set member does not exist already
- --prepend
- Add the new set member at the beginning (instead of to the end)
Output generation
--best-line-break value
-
CR, LF, CRLF or any other value
--default-flow-style FLOW|BLOCK|AUTO
-
Formatting style for generated documents
--strip-comments
-
Remove comments while transforming
--indent value
-
Number of spaces for the indent in the block flow style (default 2)
--indent-with-indicator
-
Add the indent for sequences to the general indent
--indicator-indent value
-
Add the specified indent for sequence indicator in the block flow (default 0)
--dont-split-lines
-
Don't split long lines
--width value
-
Max width for literal scalars (default 80)
Specs
Many of the options specify a path from the root of the YAML document to a node, as follows:
.identifier
.(yaml-document)
- Use the map entry with the given key, or the given sequence element, or the given set member.
[0...sequenceSize-1]
- Use the sequence element with the given index.
[-sequenceSize...-1]
- Use the sequence element with the given index plus sequenceSize.
[]
- The sequence element after the last existing.