Toml.psm1
|
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains long links.')] [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 [init] Write-Debug "[$scriptName] - [init] - Processing folder" #region [init] - [initializer] Write-Debug "[$scriptName] - [init] - [initializer] - Importing" Write-Verbose '-------------------------------' Write-Verbose '--- THIS IS AN INITIALIZER ---' Write-Verbose '-------------------------------' Write-Debug "[$scriptName] - [init] - [initializer] - Done" #endregion [init] - [initializer] Write-Debug "[$scriptName] - [init] - Done" #endregion [init] #region [functions] - [public] Write-Debug "[$scriptName] - [functions] - [public] - Processing folder" #region [functions] - [public] - [ConvertFrom-Toml] Write-Debug "[$scriptName] - [functions] - [public] - [ConvertFrom-Toml] - Importing" function ConvertFrom-Toml { <# .SYNOPSIS Converts a TOML string to a PowerShell object. .DESCRIPTION Converts a TOML formatted string into a PowerShell hashtable or object. .EXAMPLE ConvertFrom-Toml -InputObject '[database] host = "localhost" port = 5432' Converts a TOML string to a PowerShell object. #> [CmdletBinding()] param ( # The TOML string to convert. [Parameter(Mandatory)] [string] $InputObject ) $null = $InputObject throw [System.NotImplementedException] 'ConvertFrom-Toml is not yet implemented.' } Write-Debug "[$scriptName] - [functions] - [public] - [ConvertFrom-Toml] - Done" #endregion [functions] - [public] - [ConvertFrom-Toml] Write-Debug "[$scriptName] - [functions] - [public] - Done" #endregion [functions] - [public] #region [variables] - [private] Write-Debug "[$scriptName] - [variables] - [private] - Processing folder" #region [variables] - [private] - [PrivateVariables] Write-Debug "[$scriptName] - [variables] - [private] - [PrivateVariables] - Importing" $script:HabitablePlanets = @( @{ Name = 'Earth' Mass = 5.97 Diameter = 12756 DayLength = 24.0 }, @{ Name = 'Mars' Mass = 0.642 Diameter = 6792 DayLength = 24.7 }, @{ Name = 'Proxima Centauri b' Mass = 1.17 Diameter = 11449 DayLength = 5.15 }, @{ Name = 'Kepler-442b' Mass = 2.34 Diameter = 11349 DayLength = 5.7 }, @{ Name = 'Kepler-452b' Mass = 5.0 Diameter = 17340 DayLength = 20.0 } ) $script:InhabitedPlanets = @( @{ Name = 'Earth' Mass = 5.97 Diameter = 12756 DayLength = 24.0 }, @{ Name = 'Mars' Mass = 0.642 Diameter = 6792 DayLength = 24.7 } ) Write-Debug "[$scriptName] - [variables] - [private] - [PrivateVariables] - Done" #endregion [variables] - [private] - [PrivateVariables] Write-Debug "[$scriptName] - [variables] - [private] - Done" #endregion [variables] - [private] #region [variables] - [public] Write-Debug "[$scriptName] - [variables] - [public] - Processing folder" #region [variables] - [public] - [Moons] Write-Debug "[$scriptName] - [variables] - [public] - [Moons] - Importing" $script:Moons = @( @{ Planet = 'Earth' Name = 'Moon' } ) Write-Debug "[$scriptName] - [variables] - [public] - [Moons] - Done" #endregion [variables] - [public] - [Moons] #region [variables] - [public] - [Planets] Write-Debug "[$scriptName] - [variables] - [public] - [Planets] - Importing" $script:Planets = @( @{ Name = 'Mercury' Mass = 0.330 Diameter = 4879 DayLength = 4222.6 }, @{ Name = 'Venus' Mass = 4.87 Diameter = 12104 DayLength = 2802.0 }, @{ Name = 'Earth' Mass = 5.97 Diameter = 12756 DayLength = 24.0 } ) Write-Debug "[$scriptName] - [variables] - [public] - [Planets] - Done" #endregion [variables] - [public] - [Planets] #region [variables] - [public] - [SolarSystems] Write-Debug "[$scriptName] - [variables] - [public] - [SolarSystems] - Importing" $script:SolarSystems = @( @{ Name = 'Solar System' Planets = $script:Planets Moons = $script:Moons }, @{ Name = 'Alpha Centauri' Planets = @() Moons = @() }, @{ Name = 'Sirius' Planets = @() Moons = @() } ) Write-Debug "[$scriptName] - [variables] - [public] - [SolarSystems] - Done" #endregion [variables] - [public] - [SolarSystems] Write-Debug "[$scriptName] - [variables] - [public] - Done" #endregion [variables] - [public] #region [finally] Write-Debug "[$scriptName] - [finally] - Importing" Write-Verbose '------------------------------' Write-Verbose '--- THIS IS A LAST LOADER ---' Write-Verbose '------------------------------' Write-Debug "[$scriptName] - [finally] - Done" #endregion [finally] #region Member exporter $exports = @{ Alias = '*' Cmdlet = '' Function = 'ConvertFrom-Toml' Variable = @( 'Moons' 'Planets' 'SolarSystems' ) } Export-ModuleMember @exports #endregion Member exporter |