New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve comments when editing files #178
Comments
Similar issue to #175. I'll do some digging to see if I can find a decent solution to this |
@TomWright I think this one is a bit different as it doesn't use the same data structure and therefore library. Xml seems to rely on mxj while yaml depends on |
Thanks for the note on v3. It may be as easy as a version upgrade. I'll take a look |
@olblak Where did you see that v3 supports comments? |
That's a very good question. I couldn't find the changelog entry mentioning this. But I faced the same issue on https://github.com/updatecli and if I recall correctly switching to v3 solved it. |
The original issue description reports comments being stripped out from a yaml. I would like to report that I observed the same behavior with a toml. |
@tiogate I'm also interested in keeping the original comments in a toml config file. It seems that keeping comments is not supported by go-toml library at the moment (or the near future). See also pelletier/go-toml#457 |
@TomWright did you take a look at an upgrade to I definitely see comment-related fields in the |
@r10r Unfortunately I did not find a reasonable solution. In my case I only needed to modify one value in a TOML, so I did that with a hacky sed command. I also needed to make more complex modifications to JSON and YAML files though, and for that I used jq and yq. |
Sorry I haven't looked yet - I've been pretty busy lately and haven't been able to find the time to support this as much as I'd like. I haven't forgotten though |
I have an example where comments are not preserved with toml
|
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 thedasel put
command. Output does not have comments anymore.example.yaml
:dasel put string -f example.yaml .version 0.2.0
Expected output:
The text was updated successfully, but these errors were encountered: