Types/OpenPackage.Part/ReadToml.ps1
|
<# .SYNOPSIS Reads Part Content as Toml .DESCRIPTION Reads Package Part Content as Toml .LINK https://toml.io/ .LINK https://github.com/jborean93/PSToml #> [Reflection.AssemblyMetadata( # This should automatically apply to .yaml files 'FilePattern', '\.toml$' )] param( # An optional input object # If provided, content will be read from this object. # If not provided, content will be read from this part. [Alias('Input')] [PSObject]$InputObject = $null, # Any options used to read the data. [Alias('Options')] [Collections.IDictionary]$Option = [Ordered]@{} ) if (-not $this.ReadText) { return } $convertFromTomlCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand('ConvertFrom-Toml', 'Cmdlet,Function') $partString = $this.ReadText($InputObject, $Option) if (-not $convertFromTomlCommand -or -not $convertFromTomlCommand.Parameters.InputObject) { Write-Warning "ConvertFrom-Toml not found, please install PSToml" $partString } else { try { $partString | & $convertFromTomlCommand -ErrorAction Stop } catch { Write-Warning "'$($thisPart.Uri)' was not valid toml: $_" } } |