Toml.psm1
|
[CmdletBinding()] param() $baseName = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) $script:PSModuleInfo = Import-PowerShellDataFile -Path "$PSScriptRoot\$baseName.psd1" $script:PSModuleInfo | Format-List | Out-String -Stream | ForEach-Object { Write-Debug $_ } $scriptName = $script:PSModuleInfo.Name Write-Debug "[$scriptName] - Importing module" #region [functions] - [public] Write-Debug "[$scriptName] - [functions] - [public] - Processing folder" #region [functions] - [public] - [Toml] Write-Debug "[$scriptName] - [functions] - [public] - [Toml] - Processing folder" #region [functions] - [public] - [Toml] - [Get-Toml] Write-Debug "[$scriptName] - [functions] - [public] - [Toml] - [Get-Toml] - Importing" function Get-Toml { <# .SYNOPSIS Get TOML content from a file. .DESCRIPTION Reads a TOML file from disk and returns its raw text content as a single string. .EXAMPLE Get-Toml -Path '.\settings.toml' Returns the TOML content from settings.toml as a string. .INPUTS [string] .OUTPUTS [string] .NOTES This command returns raw TOML text and does not parse TOML into objects. .LINK https://github.com/PSModule/Toml #> [OutputType([string])] [CmdletBinding()] param( # Path to the TOML file. [Parameter(Mandatory, Position = 0)] [ValidateNotNullOrEmpty()] [string] $Path ) $resolvedPath = $PSCmdlet.GetUnresolvedProviderPathFromPSPath($Path) [System.IO.File]::ReadAllText($resolvedPath) } Write-Debug "[$scriptName] - [functions] - [public] - [Toml] - [Get-Toml] - Done" #endregion [functions] - [public] - [Toml] - [Get-Toml] Write-Debug "[$scriptName] - [functions] - [public] - [Toml] - Done" #endregion [functions] - [public] - [Toml] Write-Debug "[$scriptName] - [functions] - [public] - Done" #endregion [functions] - [public] #region Member exporter $exports = @{ Alias = '*' Cmdlet = '' Function = 'Get-Toml' Variable = '' } Export-ModuleMember @exports #endregion Member exporter |