Hand-written or machine-generated TOML files often have inconsistent indentation, key-quoting, and table-section ordering. A Format-Toml function normalizes the text without changing semantics — equivalent to ConvertFrom-Toml | ConvertTo-Toml but expressed as a single ergonomic call. Sister modules already follow this pattern: Format-Json and Format-Hashtable.
Request
Desired capability
Get-Content Cargo.toml -Raw | Format-Toml
Format-Toml -Path Cargo.toml -Indent 4
Parameters
| Parameter |
Description |
-InputObject |
String to format (ValueFromPipeline, default set) |
-Path |
File path to read and format |
-LiteralPath |
Literal file path |
-Indent |
Spaces per level (default: 2) |
Acceptance criteria
Format-Toml $s produces canonical-form TOML for $s
- Idempotent:
Format-Toml (Format-Toml $s) equals Format-Toml $s
-Indent controls spacing between nested table levels
- Output remains parseable by
ConvertFrom-Toml
Technical decisions
Implementation: Parses input with ConvertFrom-Toml and re-emits with ConvertTo-Toml using the requested indentation. Reuses existing logic — no new parser or emitter.
Function placement: src/functions/public/Format-Toml.ps1.
Parameter sets: InputObject (default, pipeline) and Path / LiteralPath for file input.
Alias: Format-Tml, matching the planned alias pattern in #2.
Implementation plan
Related
Hand-written or machine-generated TOML files often have inconsistent indentation, key-quoting, and table-section ordering. A
Format-Tomlfunction normalizes the text without changing semantics — equivalent toConvertFrom-Toml | ConvertTo-Tomlbut expressed as a single ergonomic call. Sister modules already follow this pattern:Format-JsonandFormat-Hashtable.Request
Desired capability
Parameters
-InputObjectValueFromPipeline, default set)-Path-LiteralPath-IndentAcceptance criteria
Format-Toml $sproduces canonical-form TOML for$sFormat-Toml (Format-Toml $s)equalsFormat-Toml $s-Indentcontrols spacing between nested table levelsConvertFrom-TomlTechnical decisions
Implementation: Parses input with
ConvertFrom-Tomland re-emits withConvertTo-Tomlusing the requested indentation. Reuses existing logic — no new parser or emitter.Function placement:
src/functions/public/Format-Toml.ps1.Parameter sets:
InputObject(default, pipeline) andPath/LiteralPathfor file input.Alias:
Format-Tml, matching the planned alias pattern in #2.Implementation plan
Format-Tomlinsrc/functions/public/Format-Toml.ps1withFormat-Tmlalias-Indent, idempotent round-tripexamples/General.ps1Related
ConvertFrom-Toml/ConvertTo-Toml(prerequisite)