Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Open-OfficeToml

Module
PSWriteOffice
Inputs
System.String
Outputs
OfficeIMO.Toml.TomlDocument System.IO.FileInfo

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: Path
Open-OfficeToml
[[-Content] <ScriptBlock>]
-LiteralPath <String>
[-Options <TomlLoadOptions>]
[-PassThru]
[-Show]
[-Untrusted]
[<CommonParameters>]
#
Parameter set: LiteralPath
Open-OfficeToml
[-Options <TomlLoadOptions>]
-Text <String>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Text
Open-OfficeToml
[-Options <TomlLoadOptions>]
-Stream <Stream>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: Stream

Description

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 $document

Parameters

-Content ScriptBlock optionalposition: 1sets: Path, LiteralPath
An optional editing block; omission returns the live document.
-Options TomlLoadOptions optional
Native load options or a hashtable of their properties: MaxDepth, MaxNodes, MaxStringLength and MaxInputBytes.
-PassThru SwitchParameter optionalsets: Path, LiteralPath
Emit the FileInfo after a completed editing block.
-Path String requiredposition: 0pipeline: True (ByValue)sets: Path
TOML file with FileSystem wildcard expansion.
-Show SwitchParameter optionalsets: Path, LiteralPath
Open the saved file after a completed editing block.
-Untrusted SwitchParameter optional
Caps every limit at the engine's untrusted defaults, for files from outside.
-LiteralPath String requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal TOML file, including FileInfo.FullName and provider PSPath.
-Text String requiredsets: Text
TOML text to parse without a file.
-Stream Stream requiredsets: 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.