🚀 [Feature]: Merge-Toml combines TOML documents into one - #21
Merged
Marius Storhaug (MariusStorhaug) merged 4 commits intoJul 26, 2026
Merged
Conversation
Adds Merge-Toml (src/functions/public/Merge-Toml.ps1) and the private recursive merge helper Merge-TomlTableObject (src/functions/private/Merge-TomlTableObject.ps1). Supports BaseObject /OverrideObject strings, -Path, and -LiteralPath parameter sets, with LastWins (default), FirstWins, and ErrorOnConflict merge strategies. Nested tables are deep-merged recursively and arrays of tables are always concatenated regardless of strategy. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Covers all three parameter sets (BaseObject/OverrideObject, -Path, -LiteralPath), all three merge strategies, nested table deep-merge, array-of-tables concatenation, output type/parseability, and idempotency under FirstWins. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Marius Storhaug (MariusStorhaug)
force-pushed
the
merge-toml-combiner
branch
from
July 26, 2026 07:49
87b531d to
79a2a5e
Compare
…ml-combiner # Conflicts: # tests/Toml.Tests.ps1
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.
Merge-Tomlcombines two or more TOML documents into one, so layered configuration — defaults plus environment overrides, or a base file plus a local override file — no longer needs ad-hoc hashtable-merging loops.New: Merge-Toml
Merge-Tomlaccepts either two TOML strings, or a list of file paths merged in order:Nested tables are always deep-merged recursively, and arrays of tables (
[[...]]) are always concatenated, base entries first. Scalar key conflicts (including inline arrays, treated as scalars) are resolved with-Strategy:LastWins(default) — the override value replaces the base valueFirstWins— the base value is keptErrorOnConflict— throws on any duplicate scalar keyThe result is always a
[string]of canonical TOML, parseable byConvertFrom-Toml.Technical details
src/functions/public/Merge-Toml.ps1with three parameter sets:Default(-BaseObject/-OverrideObject),Path, andLiteralPath.src/functions/private/Merge-TomlTableObject.ps1that walks override keys against a baseOrderedDictionary, deep-merging nested tables, concatenatingArrayListarray-of-tables, and applying-Strategyto remaining scalar conflicts.ConvertFrom-Toml/ConvertTo-Tomlfor parsing and serialization — no new parsing logic.tests/Toml.Tests.ps1for all parameter sets, all three strategies, deep-merge, AoT concatenation, file input, and idempotency.README.mdwith a usage example and addedMerge-Tomlto the command table.Invoke-ScriptAnalyzer -Path src/ -Recurseclean (no new findings), 135/135 Pester tests passing.Relevant issues (or links)