#178·dasel

Preserve comments when editing files

Author: ypicardCreated Nov 1, 2021Updated Apr 18, 2024
Labelsbug

Discussion? Don't really know if I should file this as a feature request or a bug, let me know.

Describe the bug When updating files with the dasel put command, if comments are in the original file, they get stripped out from the output file. I would like to be able to keep them if I want to - or by default.

To Reproduce Edit a yaml file containing comments with the dasel put command. Output does not have comments anymore.

  • create an original yaml file named example.yaml:
apiVersion: v2
type: application
# Comment 1
version: 0.1.0
# Comment 2
appVersion: 0.1.0
  • execute: dasel put string -f example.yaml .version 0.2.0
  • Output looks like:
apiVersion: v2
appVersion: 0.1.0
type: application
version: 0.2.0

Expected output:

apiVersion: v2
type: application
# Comment 1
version: 0.2.0
# Comment 2
appVersion: 0.1.0