Open wbrandenburger opened 4 years ago
Hello.
I like your ideas. Would gladly incorporate that into the module and release it as a new major version
Unfortunately, I do not have enough time for now. If you are willing to help, just send me a PR.
If this gets incorporated it should be optional, as it will break stuff.
Multiline Values
The INI file format does not support multiline values. This behavior if implemented should be non default as it breaks exiting scripts, for example:
[Multiline Values]
chorus=I'm a lumberjack, and I'm okay
idented_key=I sleep all night and I work all day
Here, idented key will be taken as a part of above key.
Interpolation of values Moreover, there is the oppurtunity to use environment variables as values.
Env vars are typically used for this. It makes sence to expand env vars, possibly as an option when getting values. The problem here is writting values back - if I read and imediatelly write values all vars would get expanded and removed. WIth behavior like that its almost useless feature. Module will have to write back those env vars if key values containing them were unchanged.
I totally agree, it has to be optional. The described behavior will be a problem, if set as default. I will consider that.
In default behavior, I think that highest possible compatibility with Windows API should be the goal as that behavior is what will be expected by most. Anything else can be added as configurable feature or fun parameter. This could also be tested easily.
I personally started using this one but because it wasn't compatible with WIndows API it changed ini files in ways that are not semantically equal to starting ini file. I finially used custom Ini script that calls Windows API Profile functions.
about the multiline:
chorus=I'm a lumberjack, and I'm okay idented_key=I sleep all night and I work all day
I found this note
Following the syntax of the language it is designed to work with (Python), to span a node over multiple lines ConfigParser requires a deeper indentation in the lines that follow, instead of the more common backslash + line break (see: configparser — Configuration file parser)
@majkinetor
because it wasn't compatible with WIndows API
What part of this module is currently not compatible? :-o
Part #50 :) Also trimming of values.
Servus,
I'm working a lot with python and its parser for config files. There are several characteristics of an ini file structure, which are not considered in PSIni:
Multiline Values
Indented lines enable multiline values,
which can be easily considered when insert the evaluation of a
Regex
-string ,e.g.,^( {4,}.*)\s*$,
after inserting a key inGet-IniContent
.Interpolation of values
It enables values to contain format strings which refer to other values in the same section, or values in the special default section. Additionally extended interpolation enables to denote a value from a foreign section.
Moreover, there is the oppurtunity to use environment variables as values.
I have implemented already these functionality but for the last published version in PSGallery 3.1.2. Is there the possibility to open a pull request for version 4.0?
Besides these extensions, there seems to be a misbehaviour when using redundant keys in one section. In
Get-IniContent
, the generation of[ArrayList]
overwrites the current key and logically add to this key a empty object of[ArrayList]
. I think, that behaviour is not intended and can be easily fixed.I'm looking forward hearing from you!