3 ms·
I think the issue with comments runs a bit deeper and is more pervasive than the (sad) fact that plain JSON does not support them. Case in point, I just tried a
by DemocracyFTW2 2y ago
I think the issue with comments runs a bit deeper and is more pervasive than the (sad) fact that plain JSON does not support them. Case in point, I just tried and improved a frequently-used piece of 3rd-party software (written in Python) that I use as a CLI tool. Because I use it frequently I want to pass in parameters on the command line instead of editing a TOML file, so I got myself a TOML parser and wrote a teeny NodeJS script that reads the TOML and returns an object on which I set a property according to the argv value, then serialize it and write out to the TOML file, then run that Python tool which grabs the value from the config. Nice kludge and all BUT, as a matter of course, the code comments in the TOML file that instruct users what the entries are for and so on—those are gone after the update. I fixed that problem by making a copy of the original TOML file.
So long whine short, I believe comments should have some kind of 1st class status in configuration files and tools should ideally offer to preserve them even when settings are updated, and to delete them when e.g. talking to another electronic machine over the telephone network, if you know what I mean. The same really goes for comments in other languages like JS, CSS, HTML: they're quite often just fly-over territory, but sometimes, just sometimes folks, they should be kept, and I don't see a great many tools that readily give me that option.
- 7jjjjjjj 2y agoThis project claims to do that: https://pypi.org/project/tomlkit/ https://pypi.org/project/tomlkit/
- DemocracyFTW2 2y agokudos!