Once ConvertFrom-Toml and ConvertTo-Toml land (#2), scripts working with .toml files will still need to combine them with Get-Content -Raw / Set-Content for every file operation. Every other PowerShell serialization format ships file-I/O wrappers — Import-Csv / Export-Csv, Import-Clixml / Export-Clixml, Import-PowerShellDataFile. Users expect the same convenience for TOML.
Request
Desired capability
$config = Import-Toml -Path Cargo.toml
$config | Export-Toml -Path Cargo.toml
$config | Export-Toml -Path Cargo.toml -NoClobber
Standard parameters
| Parameter |
Import-Toml |
Export-Toml |
Description |
-Path |
✓ |
✓ |
File path (position 0) |
-LiteralPath |
✓ |
✓ |
Literal path (no wildcard expansion) |
-Encoding |
✓ |
✓ |
Default utf8NoBOM (TOML spec mandates UTF-8) |
-InputObject |
— |
✓ |
ValueFromPipeline |
-NoClobber |
— |
✓ |
Fail if target exists |
-Force |
— |
✓ |
Overwrite read-only files |
All ConvertFrom-Toml / ConvertTo-Toml parameters pass through.
Acceptance criteria
Import-Toml -Path f.toml returns the same object as Get-Content f.toml -Raw | ConvertFrom-Toml
$o | Export-Toml -Path f.toml produces the same content as $o | ConvertTo-Toml | Set-Content f.toml
-NoClobber, -Force, -Encoding, -LiteralPath behave as in Export-Csv / Import-Csv
ShouldProcess support (-WhatIf, -Confirm) on Export-Toml
- Round-trip via file:
$o | Export-Toml -Path $f; Import-Toml -Path $f produces an equivalent object
Technical decisions
Architecture: Thin wrappers around ConvertFrom-Toml / ConvertTo-Toml. All format logic stays in the Convert functions.
Function placement: src/functions/public/Import-Toml.ps1 and src/functions/public/Export-Toml.ps1.
Parameter sets: Path (default, position 0) and LiteralPath, mirroring Import-Csv.
Encoding default: UTF-8 without BOM, per the TOML 1.0 specification which mandates UTF-8.
Aliases: Import-Tml / Export-Tml, matching the planned ConvertFrom-Tml / ConvertTo-Tml aliases in #2.
Breaking changes: None. New functions only.
Implementation plan
Related
Once
ConvertFrom-TomlandConvertTo-Tomlland (#2), scripts working with.tomlfiles will still need to combine them withGet-Content -Raw/Set-Contentfor every file operation. Every other PowerShell serialization format ships file-I/O wrappers —Import-Csv/Export-Csv,Import-Clixml/Export-Clixml,Import-PowerShellDataFile. Users expect the same convenience for TOML.Request
Desired capability
Standard parameters
-Path-LiteralPath-Encodingutf8NoBOM(TOML spec mandates UTF-8)-InputObjectValueFromPipeline-NoClobber-ForceAll
ConvertFrom-Toml/ConvertTo-Tomlparameters pass through.Acceptance criteria
Import-Toml -Path f.tomlreturns the same object asGet-Content f.toml -Raw | ConvertFrom-Toml$o | Export-Toml -Path f.tomlproduces the same content as$o | ConvertTo-Toml | Set-Content f.toml-NoClobber,-Force,-Encoding,-LiteralPathbehave as inExport-Csv/Import-CsvShouldProcesssupport (-WhatIf,-Confirm) onExport-Toml$o | Export-Toml -Path $f; Import-Toml -Path $fproduces an equivalent objectTechnical decisions
Architecture: Thin wrappers around
ConvertFrom-Toml/ConvertTo-Toml. All format logic stays in the Convert functions.Function placement:
src/functions/public/Import-Toml.ps1andsrc/functions/public/Export-Toml.ps1.Parameter sets:
Path(default, position 0) andLiteralPath, mirroringImport-Csv.Encoding default: UTF-8 without BOM, per the TOML 1.0 specification which mandates UTF-8.
Aliases:
Import-Tml/Export-Tml, matching the plannedConvertFrom-Tml/ConvertTo-Tmlaliases in #2.Breaking changes: None. New functions only.
Implementation plan
Import-Tomlinsrc/functions/public/Import-Toml.ps1withImport-TmlaliasExport-Tomlinsrc/functions/public/Export-Toml.ps1withExport-Tmlaliastests/Import-Toml.Tests.ps1— basic read,-Encoding,-LiteralPath, missing filetests/Export-Toml.Tests.ps1— basic write,-NoClobber,-Force,-Encoding,-WhatIf, pipeline inputexamples/General.ps1and READMERelated
ConvertFrom-Toml/ConvertTo-Toml(prerequisite)