Cmdlet
Open-OfficeToml
Opens a TOML file, stream or text as a lossless live document; a file content block saves atomically.
Syntax
Open-OfficeToml
[[-Content] <ScriptBlock>]
[-Options <TomlLoadOptions>]
[-PassThru]
[-Path] <String>
[-Show]
[-Untrusted]
[<CommonParameters>]#Parameter set:
PathOpen-OfficeToml
[[-Content] <ScriptBlock>]
-LiteralPath <String>
[-Options <TomlLoadOptions>]
[-PassThru]
[-Show]
[-Untrusted]
[<CommonParameters>]#Parameter set:
LiteralPathOpen-OfficeToml
[-Options <TomlLoadOptions>]
-Text <String>
[-Untrusted]
[<CommonParameters>]#Parameter set:
TextOpen-OfficeToml
[-Options <TomlLoadOptions>]
-Stream <Stream>
[-Untrusted]
[<CommonParameters>]#Parameter set:
StreamDescription
Saving writes only what changed: comments, blank lines, quoting, key order, alignment and the spelling of every other value stay byte for byte. Malformed input fails with an error ID built from the engine's code (for example toml-Toml.Load.DuplicateKey), and the message gives the line and column.
Examples
Change one value and keep the rest of the file as it was.
Open-OfficeToml -Path ./pyproject.toml {
Set-OfficeTomlNode -Select 'project.version' -Value '1.2.0'
}Read an uploaded file with untrusted limits.
$document = Open-OfficeToml -LiteralPath ./uploads/Cargo.toml -Untrusted
Get-OfficeTomlNode -Document $document -Select 'package.name'
Close-OfficeToml -Document $documentParameters
- -Content ScriptBlock
- An optional editing block; omission returns the live document.
- -Options TomlLoadOptions
- Native load options or a hashtable of their properties: MaxDepth, MaxNodes, MaxStringLength and MaxInputBytes.
- -PassThru SwitchParameter
- Emit the FileInfo after a completed editing block.
- -Path String
- TOML file with FileSystem wildcard expansion.
- -Show SwitchParameter
- Open the saved file after a completed editing block.
- -Untrusted SwitchParameter
- Caps every limit at the engine's untrusted defaults, for files from outside.
- -LiteralPath String
- Literal TOML file, including FileInfo.FullName and provider PSPath.
- -Text String
- TOML text to parse without a file.
- -Stream Stream
- A readable stream, read from its current position; it stays open.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.