faq
faq copied to clipboard
faq to read/write ini files?
Any consderation of support for .ini files, the somewhat standardized format often used for config files?
I see a Go library https://github.com/go-ini/ini that could be useful, and there's a proof of concept (in Ruby) called dupervisor
or dv
https://github.com/kigster/dupervisor that provides a 3-way yaml/json/ini tricoder but no filter/manipulation.
Interesting! I always had thought that ini was unspecified and thus a parsing nightmare depending on what program or person created the file. This looks doable, but I clearly need to familiarize myself with ini a bit more to understand any corner cases.
If anyone is interested in implementing this or is familiar enough to talk on behalf of ini, I'm all ears.
Yeah, I expect that there's some skew possible due the lack of standards, so I'm perfectly willing to guess that this is arbitrarily hard to get exactly right for every possible version.
A quick look at other code that does this perhaps to help the next person along:
- PHP function parse_ini_file(): https://www.php.net/manual/en/function.parse-ini-file.php
- Python 3 configparser(): https://docs.python.org/3/library/configparser.html
- "simple INI parser in C", inih: https://github.com/benhoyt/inih
- C# parser: https://github.com/rickyah/ini-parser
Of these the last, ini-parser
, perhaps has the most flexibility in dealing with the existing variation in file types, and https://github.com/rickyah/ini-parser/wiki/Configuring-parser-behavior gives you some idea of the degrees of freedom that have evolved in response.