pixelb / crudini

A utility for manipulating ini files
GNU General Public License v2.0
443 stars 60 forks source link

Support for "[[section]]" #48

Open JimboJoe opened 7 years ago

JimboJoe commented 7 years ago

Configuration files use sometimes sections with double brackets (e.g. [[graphite]] in influxdb.conf or [[servers]] in ldap.toml for Grafana), but this syntax seems to be actually unsupported. Would it be possible to support that? Thanks!

pixelb commented 7 years ago

Right, we explicitly disallow that since commit 50718ed6, as without that commit we could read and write existing section contents containing extra [ ... ] but we can't write new sections or get section names with [ ... ] so that would be inconsistent.

Extra [ ... ] are also used (with reason) in http://editorconfig.org/#file-format-details

Also I think the php ini parsers supports this format.

Now it's a bit of a gotcha that people might specify the '[section]' with brackets with --set, which might create extraneous sections, so maybe we should support this with an option. Options are best avoided of course, so we might just support unconditionally

tobixx commented 6 years ago

I want to express also my interest in this issue. I'm not sure if my use case is identical with the original reporter because for me the double brackets means subsections. Usually we parse/write it with configobj where this is directly supported. For the cli interface my idea would be that any arg but the last one should be interpreted as (sub-)sections traversing the hierarchy.