config-parser icon indicating copy to clipboard operation
config-parser copied to clipboard

Extend array declaration capabilities (with possible breaking change)

Open Krakean opened this issue 6 years ago • 3 comments

Currently, arrays can be declared only this way: arrayWorkToo = arrayElement1 arrayElement2

My suggestion is possibly remove such way of defining them (may be to make parsing a bit more strict), and instead allow these: arrayWorkToo = [ 1, 2, 3 ] arrayWorkToo = [ “red”, “yellow”, “black” ] arrayWorkToo = [ [ 1, 2 ], [3, 4, 5] ] arrayWorkToo = [ arrayElement1, arrayElement2 ] arrayWorkToo = [ { x = 1, y = 2, z = 3 }, { x = 4, y = 5, z = 6} ]

Krakean avatar Jun 03 '19 18:06 Krakean

Defacto there are few standards for reading/writing arrays in .ini/.conf files. I've simply implemented the one I've seen in Python applications I had to share config files with.

Examples: https://wakatime.com/faq#exclude-paths https://stackoverflow.com/questions/4097139/reading-array-from-config-file-in-python/47891483#answer-11296626

So I cannot accept your request to drop the support of this format, I think I will implement some sort of setting for array format instead.

salaros avatar Jun 07 '19 16:06 salaros

I have a related request so I'm just putting this in here instead of making a new issue.

Could you make it possible to read duplicate keys?

Like

[mySection]
value=abc
value=def

So that I can get an array containing "abc" and "def"? Just being able to read it would be good enough for starters I think.

I guess I can manage for now with a loop but it would be nice to have.

TomArrow avatar Aug 20 '21 14:08 TomArrow

@TomArrow makes sense

salaros avatar Aug 20 '21 17:08 salaros