Closed heilkn closed 5 years ago
Regarding the duplicate names: I think it is up to the program how to interprete the ini file. However, when dealing with ini files on the command line, you usually want to do changes to an existing file. If you know, a program does not support multiple entries, don't create any. If a program does, then the tool is of no help if it can't support that.
Also: can you please add tests for this new behavior?
@lipkau Please let me know if you think more work is required on this, before it can be merged.
Dear @lipkau
FYI - Similar problem as with versions 1.2.38 / 42 and 2.0.0.0:
This change introduces a breaking change between version 2.0.5 and 2.0.6. For sections with non-duplicate keys, there will be also returned an array instead of a string.
Example:
my.ini
[Trace]
Path=C:\temp
PurgeAfterDays=5
Level=Warning
behavior 2.0.5
> Import-Module PsIni -MaximumVersion 2.0.5
> $c = Get-IniContent -FilePath C:\temp\my.ini
> $c.Trace
Name Value
---- -----
Path C:\temp
PurgeAfterDays 5
Level Warning
> $c.Trace.Path.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
behavior 2.0.6
> Import-Module PsIni -MinimumVersion 2.0.6
> $c = Get-IniContent -FilePath C:\temp\my.ini
> $c.Trace
Name Value
---- -----
Path {C:\temp}
PurgeAfterDays {5}
Level {Warning}
PS C:\Users\ese> $c.Trace.Path.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
Because I have to support PsIni version 2.x, I have to deal with both behaviors. As workaround I need to test the value with -is [array]. But that's manageable.
Best regards Elia
I am surprised it works for you.
I just tried to run it with powershell -version 2
(I know it's not the same thing) and got this error
ipmo : The '.\PSIni\PSIni.psd1' module cannot be imported because its manifest contains one or more members that are not valid.
I expressed myself wrong: I don't have to support Powershell 2.0, I need to support PsIni in Version 2.X. I told my users: "To use my module, you need PsIni in Major/Minor-Version 2.0, because my module reads and writes ini-files."
I don't have control over all systems where my module is running. Some of my ini-related module-functions are now failling when someone updates PsIni from <=2.0.5 to 2.0.6 because of the behavior changes in this pull request.
In my next module version, I will use PsIni as nested module to be sure, which version of PsIni my module is using. This will remove the external dependency to PsIni.
Cool. Thank you.
Dear lipkau,
thank you very much for the great tool. When I wanted to use it, I encountered the problem that the ini files I have to modify contain several keys in a section with the same name. Therefore, I'd like to propose to read in those entries as an array.
Please consider adding this feature. This pullrequest is a simple approach to solve that problem. Probably, Set-IniContent and Out-IniFile needs adaption, too. I think you will know best which adjustments need to be made. However, if you are not able to do the necessary changes, please let me know what is required.
Kind regards
Konstantin