Cmdlet "Merge-INI", merging INI files#265
Draft
RattleSN4K3 wants to merge 1 commit intoLANCommander:mainfrom
Draft
Cmdlet "Merge-INI", merging INI files#265RattleSN4K3 wants to merge 1 commit intoLANCommander:mainfrom
RattleSN4K3 wants to merge 1 commit intoLANCommander:mainfrom
Conversation
Contributor
Author
|
Needs additional testing with different use cases. For now only a "draft" |
Collaborator
|
This is awesome! I created #164 with this sort of intention in mind, but of course it's not limited to just servers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cmdlet "Merge-INI", utilizing MadMilkman.INI for ini merging
Note
Based on PR #260 (required for MadMilkman.INI) which is now merged.
This includes the following:
Use case
A specific use case I have in mind is a mod which patches the the game files' INI with specific properties. On uninstallation of the mod, the changes are reverted.
UT2004 and patch/mod to apply "Master-Server" changes
Game: UT2004
Mod: UT2004 MasterPatch
Install Script:
Uninstall Script:
The mod has the
System\MasterPatch.inias archive. On installation it will merge the ini with creating a backup. On uninstallation the maser patch is reverted by applying the backup data.Examples
The following example INI file is used for all examples.
config.ini
patch.ini
( click for examples )
Example 1: Simple Merge (Update Existing)
Result:
The cmdlet processes the entire source file and merges the
[IpDrv.MasterServerLink]section. Since the destination already contains twoMasterServerListentries, each patch entry updates the last matching entry. Multi-Value parameters need clearing and preserving. In the end, the destination section becomes:Note: Only the last patch value is visible because each patch line revised the same key entry.
Example 2: Merge with Appending (respectively perserving keys)
Result:
With the
-PreserveKeys(short:-append) switch, each MasterServerList entry from the patch is appended. The destination section now contains its original entries plus all three patch entries:Example 3: Merge with Clear
Result:
Introducing the
-Clearswitch first removes all existingMasterServerListentries in the destination. Then, with-PreserveKeys, the patch file's entries are added:Example 4: Extract Entire Section
Result:
Here, only the
[IpDrv.MasterServerLink]section from the config is merged/extracted into the destination. After merging, that section is removed fromconfig.ini.The backup file becomes:
And the config file no longer contains the
[IpDrv.MasterServerLink]section.Example 5: Extract Specific Key
Result:
Only the
MasterServerListkey is merged from the specified section. It is created as a Backup first inMasterServerList_Backup. The destination section becomes:In the config file, the
MasterServerListkey is backupped and removed. The patch is applied and merged into the same section.Example 6: Remove Section
Result:
Only the
MasterServerListkey is removed from the specified section. No additional file is created. The destination section becomes:Wiki
Merge-Ini
Merge-Ini
Merges the sections and keys of one INI file into another INI file.
Syntax