4 ms·
Graybeard opinion: all of toml, yaml, xml, json, kdl, etc., are ridiculously over-engineered for simple configuration files. You can nearly always fulfill all
by enriquto 3y ago
Graybeard opinion: all of toml, yaml, xml, json, kdl, etc., are ridiculously over-engineered for simple configuration files. You can nearly always fulfill all of your needs with a simple two-column text file of key=value pairs that can be parsed by a trivial call to fscanf(3) or whatever your laguage supports (yes, even correctly discarding comments). The world would be a better place if people just gron'd their jsons, xml2'd their xmls and so on, thus pruning the universal dependency tree by a considerable amount.
- rfoo 3y ago--flagfile gets me really far but to be fair it sucks when you need nested kv
- enriquto 3y agojust use longer keys (with an ad-hoc separator, if you want)
- rfoo 3y agoWhat about lists? Something like: --allowed-downtime-0-start=20230523170000Z --allowed-downtime-0-end=20230523170500Z --allowed-downtime-1-start=... Or --allowed-downtime-start='20230523170000Z,...' I can live with them, but neither looks clean :( Genuine question, as I actually like the plain old flagfiles/Java-properties-ish style.
- enriquto 3y agoThe output produced by gron looks quite clean to me. You just write your file as if it was a list of js variable assignments. allowed-downtime[0][0] = 20230523170000Z allowed-downtime[0][1] = 20230523170500Z allowed-downtime[1][0] = ... or if you absolutely want the names, you can make a "list of dictionaries": allowed-downtime[0].start = ...
- Rapzid 3y agoHow do you handle data structures in your key/value world? Parse it out of some adhoc key string schema?
- adgjlsfhk1 3y agoHow does this deal with needing to represent nested data? (the example coming to me now is TOML as a list of libraries each of which has a number of dependencies). I guess you can always do it by duplication, but for a human oriented format, that sounds pretty painful.
- xedrac 3y agoWith freeform keys, you can nest all day. But you'll likely just reinvent the wheel when you want certain features. aaa.bbb.enabled = true aaa.ccc.enabled = true
- enriquto 3y ago> for a human oriented format, that sounds pretty painful As a human, I prefer to edit by hand an unordered list of key-value pairs (even if the keys are long), than a json object. I often find myself using gron/ungron to edit json data by hand in a comfortable manner. The fact that several implementations of gron exist suggests that I'm not alone in this preference. Editing json requires a global understanding of the structure. But on a list of keys/values there is no order, and each line stands for itself and is understandable in isolation.