yq
yq copied to clipboard
Preserve indentation level and line break position when using --yaml-roundtrip
When using yaml-roundtrip, the style of blocks is preserved, but the indentation and position of line breaks is not. Example:
test.yml
:
test: >
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
est laborum.
yq -Y . test.yml
:
test: >
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
My use case is using yq
to programmatically edit large YAML files that are checked in to source control. It is preferable in this case to have the smallest amount of changes possible, and no changes which do not impact the actual data.
Not sure of the feasibility of detecting these types of differences. I am sure it is less straightforward than simply detecting the style of a block/scalar