diff --git a/.github/mkdocs.yml b/.github/mkdocs.yml deleted file mode 100644 index 67bd37a..0000000 --- a/.github/mkdocs.yml +++ /dev/null @@ -1,81 +0,0 @@ -# The '-{{ ... }}-'' are variables that are replaced during deployment, so no need to change. -# Rest of the settings can be changed as per your requirements. -# -# References: -# - https://squidfunk.github.io/mkdocs-material/setup/ - -site_name: -{{ REPO_NAME }}- -theme: - name: material - language: en - font: - text: Roboto - code: Sono - logo: Assets/icon.png - favicon: Assets/icon.png - palette: - # Palette toggle for automatic mode - - media: "(prefers-color-scheme)" - toggle: - icon: material/link - name: Switch to dark mode - # Palette toggle for dark mode - - media: '(prefers-color-scheme: dark)' - scheme: slate - toggle: - primary: black - accent: green - icon: material/toggle-switch-off-outline - name: Switch to light mode - # Palette toggle for light mode - - media: '(prefers-color-scheme: light)' - scheme: default - toggle: - primary: indigo - accent: green - icon: material/toggle-switch - name: Switch to system preference - icon: - repo: material/github - features: - - navigation.instant - - navigation.instant.progress - - navigation.indexes - - navigation.top - - navigation.tracking - - navigation.expand - - search.suggest - - search.highlight - -repo_name: -{{ REPO_OWNER }}-/-{{ REPO_NAME }}- -repo_url: https://github.com/-{{ REPO_OWNER }}-/-{{ REPO_NAME }}- - -plugins: - - search - -markdown_extensions: - - toc: - permalink: true # Adds a link icon to headings - - attr_list - - admonition - - md_in_html - - pymdownx.details # Enables collapsible admonitions - -extra: - social: - - icon: fontawesome/brands/discord - link: https://discord.gg/jedJWCPAhD - name: -{{ REPO_OWNER }}- on Discord - - icon: fontawesome/brands/github - link: https://github.com/-{{ REPO_OWNER }}-/ - name: -{{ REPO_OWNER }}- on GitHub - consent: - title: Cookie consent - description: >- - We use cookies to recognize your repeated visits and preferences, as well - as to measure the effectiveness of our documentation and whether users - find what they're searching for. With your consent, you're helping us to - make our documentation better. - actions: - - accept - - reject diff --git a/.github/workflows/Process-PSModule.yml b/.github/workflows/Process-PSModule.yml index dceb2e0..f2b9b43 100644 --- a/.github/workflows/Process-PSModule.yml +++ b/.github/workflows/Process-PSModule.yml @@ -27,6 +27,6 @@ permissions: jobs: Process-PSModule: - uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@11117919e65242d3388727819a751f74ad24ea9e # v5.5.0 + uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@fb1bdb8fefd243292f779d2a856a38db6fe6daf4 # v6.1.13 secrets: APIKEY: ${{ secrets.APIKEY }} diff --git a/README.md b/README.md index 6319793..f12b1d2 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,31 @@ -# {{ NAME }} +# Toml -{{ DESCRIPTION }} - -## Prerequisites - -This uses the following external resources: -- The [PSModule framework](https://github.com/PSModule/Process-PSModule) for building, testing and publishing the module. +Toml is a PowerShell module for reading TOML file content from disk so scripts can load and process configuration text. ## Installation -To install the module from the PowerShell Gallery, you can use the following command: - -```powershell -Install-PSResource -Name {{ NAME }} -Import-Module -Name {{ NAME }} -``` - -## Usage - -Here is a list of example that are typical use cases for the module. - -### Example 1: Greet an entity - -Provide examples for typical commands that a user would like to do with the module. +Install the module from the PowerShell Gallery: ```powershell -Greet-Entity -Name 'World' -Hello, World! +Install-PSResource -Name Toml +Import-Module -Name Toml ``` -### Example 2 +## Capabilities -Provide examples for typical commands that a user would like to do with the module. +Use this command to read TOML content from a file path: ```powershell -Import-Module -Name PSModuleTemplate +Get-Toml -Path '.\settings.toml' ``` -### Find more examples - -To find more examples of how to use the module, please refer to the [examples](examples) folder. - -Alternatively, you can use the Get-Command -Module 'This module' to find more commands that are available in the module. -To find examples of each of the commands you can use Get-Help -Examples 'CommandName'. - ## Documentation -Link to further documentation if available, or describe where in the repository users can find more detailed documentation about -the module's functions and features. - -## Contributing - -Coder or not, you can contribute to the project! We welcome all contributions. - -### For Users +Documentation is published at [psmodule.io/Toml](https://psmodule.io/Toml/). -If you don't code, you still sit on valuable information that can make this project even better. If you experience that the -product does unexpected things, throw errors or is missing functionality, you can help by submitting bugs and feature requests. -Please see the issues tab on this project and submit a new issue that matches your needs. +Use PowerShell help and command discovery for details: -### For Developers - -If you do code, we'd love to have your contributions. Please read the [Contribution guidelines](CONTRIBUTING.md) for more information. -You can either help by picking up an existing issue or submit a new one if you have an idea for a new feature or improvement. - -## Acknowledgements - -Here is a list of people and projects that helped this project in some way. +```powershell +Get-Command -Module Toml +Get-Help -Name Get-Toml -Examples +``` diff --git a/examples/General.ps1 b/examples/General.ps1 deleted file mode 100644 index f29e88d..0000000 --- a/examples/General.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -<# - .SYNOPSIS - This is a general example of how to use the Toml module. -#> - -# Import the module -Import-Module -Name 'Toml' - -# Convert a TOML string to a PowerShell object -$toml = @' -[database] -host = "localhost" -port = 5432 -'@ -ConvertFrom-Toml -InputObject $toml diff --git a/src/README.md b/src/README.md deleted file mode 100644 index af76160..0000000 --- a/src/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Details - -For more info about the expected structure of a module repository, please refer to [Build-PSModule](https://github.com/PSModule/Build-PSModule) diff --git a/src/assemblies/LsonLib.dll b/src/assemblies/LsonLib.dll deleted file mode 100644 index 3661807..0000000 Binary files a/src/assemblies/LsonLib.dll and /dev/null differ diff --git a/src/finally.ps1 b/src/finally.ps1 deleted file mode 100644 index d8fc207..0000000 --- a/src/finally.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -Write-Verbose '------------------------------' -Write-Verbose '--- THIS IS A LAST LOADER ---' -Write-Verbose '------------------------------' diff --git a/src/formats/CultureInfo.Format.ps1xml b/src/formats/CultureInfo.Format.ps1xml deleted file mode 100644 index a715e08..0000000 --- a/src/formats/CultureInfo.Format.ps1xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - System.Globalization.CultureInfo - - System.Globalization.CultureInfo - - - - - 16 - - - 16 - - - - - - - - LCID - - - Name - - - DisplayName - - - - - - - - diff --git a/src/formats/Mygciview.Format.ps1xml b/src/formats/Mygciview.Format.ps1xml deleted file mode 100644 index 4c972c2..0000000 --- a/src/formats/Mygciview.Format.ps1xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - mygciview - - System.IO.DirectoryInfo - System.IO.FileInfo - - - PSParentPath - - - - - - 7 - Left - - - - 26 - Right - - - - 26 - Right - - - - 14 - Right - - - - Left - - - - - - - - ModeWithoutHardLink - - - LastWriteTime - - - CreationTime - - - Length - - - Name - - - - - - - - diff --git a/src/functions/public/ConvertFrom-Toml.ps1 b/src/functions/public/ConvertFrom-Toml.ps1 deleted file mode 100644 index 7e67845..0000000 --- a/src/functions/public/ConvertFrom-Toml.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -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.' -} diff --git a/src/functions/public/Toml/Get-Toml.ps1 b/src/functions/public/Toml/Get-Toml.ps1 new file mode 100644 index 0000000..beb853e --- /dev/null +++ b/src/functions/public/Toml/Get-Toml.ps1 @@ -0,0 +1,36 @@ +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) +} diff --git a/src/functions/public/Toml/Toml.md b/src/functions/public/Toml/Toml.md new file mode 100644 index 0000000..01def8c --- /dev/null +++ b/src/functions/public/Toml/Toml.md @@ -0,0 +1,7 @@ +# Toml + +Public commands for reading TOML content from files. + +## Commands + +- `Get-Toml`: Reads TOML file content and returns it as raw text. diff --git a/src/header.ps1 b/src/header.ps1 deleted file mode 100644 index cc1fde9..0000000 --- a/src/header.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Contains long links.')] -[CmdletBinding()] -param() diff --git a/src/init/initializer.ps1 b/src/init/initializer.ps1 deleted file mode 100644 index 28396fb..0000000 --- a/src/init/initializer.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -Write-Verbose '-------------------------------' -Write-Verbose '--- THIS IS AN INITIALIZER ---' -Write-Verbose '-------------------------------' diff --git a/src/manifest.psd1 b/src/manifest.psd1 deleted file mode 100644 index ff720bd..0000000 --- a/src/manifest.psd1 +++ /dev/null @@ -1,5 +0,0 @@ -# This file always wins! -# Use this file to override any of the framework defaults and generated values. -@{ - ModuleVersion = '0.0.0' -} diff --git a/src/modules/OtherPSModule.psm1 b/src/modules/OtherPSModule.psm1 deleted file mode 100644 index 5d6af8e..0000000 --- a/src/modules/OtherPSModule.psm1 +++ /dev/null @@ -1,19 +0,0 @@ -function Get-OtherPSModule { - <# - .SYNOPSIS - Performs tests on a module. - - .DESCRIPTION - A longer description of the function. - - .EXAMPLE - Get-OtherPSModule -Name 'World' - #> - [CmdletBinding()] - param( - # Name of the person to greet. - [Parameter(Mandatory)] - [string] $Name - ) - Write-Output "Hello, $Name!" -} diff --git a/src/scripts/loader.ps1 b/src/scripts/loader.ps1 deleted file mode 100644 index 973735a..0000000 --- a/src/scripts/loader.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -Write-Verbose '-------------------------' -Write-Verbose '--- THIS IS A LOADER ---' -Write-Verbose '-------------------------' diff --git a/src/types/DirectoryInfo.Types.ps1xml b/src/types/DirectoryInfo.Types.ps1xml deleted file mode 100644 index aef538b..0000000 --- a/src/types/DirectoryInfo.Types.ps1xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - System.IO.FileInfo - - - Status - Success - - - - - System.IO.DirectoryInfo - - - Status - Success - - - - diff --git a/src/types/FileInfo.Types.ps1xml b/src/types/FileInfo.Types.ps1xml deleted file mode 100644 index 4cfaf6b..0000000 --- a/src/types/FileInfo.Types.ps1xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - System.IO.FileInfo - - - Age - - ((Get-Date) - ($this.CreationTime)).Days - - - - - diff --git a/src/variables/private/PrivateVariables.ps1 b/src/variables/private/PrivateVariables.ps1 deleted file mode 100644 index f1fc2c3..0000000 --- a/src/variables/private/PrivateVariables.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -$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 - } -) diff --git a/src/variables/public/Moons.ps1 b/src/variables/public/Moons.ps1 deleted file mode 100644 index dd0f33c..0000000 --- a/src/variables/public/Moons.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -$script:Moons = @( - @{ - Planet = 'Earth' - Name = 'Moon' - } -) diff --git a/src/variables/public/Planets.ps1 b/src/variables/public/Planets.ps1 deleted file mode 100644 index 5927bc5..0000000 --- a/src/variables/public/Planets.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -$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 - } -) diff --git a/src/variables/public/SolarSystems.ps1 b/src/variables/public/SolarSystems.ps1 deleted file mode 100644 index acbcedf..0000000 --- a/src/variables/public/SolarSystems.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -$script:SolarSystems = @( - @{ - Name = 'Solar System' - Planets = $script:Planets - Moons = $script:Moons - }, - @{ - Name = 'Alpha Centauri' - Planets = @() - Moons = @() - }, - @{ - Name = 'Sirius' - Planets = @() - Moons = @() - } -) diff --git a/tests/Get-Toml.Tests.ps1 b/tests/Get-Toml.Tests.ps1 new file mode 100644 index 0000000..ed9d8d9 --- /dev/null +++ b/tests/Get-Toml.Tests.ps1 @@ -0,0 +1,14 @@ +Describe 'Get-Toml' { + It 'Returns raw TOML content from file' { + $path = Join-Path -Path $TestDrive -ChildPath 'sample.toml' + $expected = @' +[database] +host = "localhost" +port = 5432 +'@ + + Set-Content -LiteralPath $path -Value $expected -NoNewline + + Get-Toml -Path $path | Should -BeExactly $expected + } +} diff --git a/tests/Toml.Tests.ps1 b/tests/Toml.Tests.ps1 deleted file mode 100644 index dfdbc33..0000000 --- a/tests/Toml.Tests.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -[Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSReviewUnusedParameter', '', - Justification = 'Required for Pester tests' -)] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute( - 'PSUseDeclaredVarsMoreThanAssignments', '', - Justification = 'Required for Pester tests' -)] -[CmdletBinding()] -param() - -Describe 'Module' { - It 'Function: ConvertFrom-Toml - Throws NotImplementedException' { - { ConvertFrom-Toml -InputObject '[database]' } | Should -Throw - } -} diff --git a/zensical.toml b/zensical.toml new file mode 100644 index 0000000..34d60b7 --- /dev/null +++ b/zensical.toml @@ -0,0 +1,69 @@ +[project] +site_name = "Toml" +repo_name = "PSModule/Toml" +repo_url = "https://github.com/PSModule/Toml" + +[project.theme] +variant = "classic" +language = "en" +logo = "Assets/icon.png" +favicon = "Assets/icon.png" +features = [ + "navigation.instant", + "navigation.instant.progress", + "navigation.indexes", + "navigation.top", + "navigation.tracking", + "navigation.expand", + "search.suggest", + "search.highlight", + "content.code.copy" +] + +[[project.theme.palette]] +media = "(prefers-color-scheme)" +toggle.icon = "lucide/sun-moon" +toggle.name = "Switch to dark mode" + +[[project.theme.palette]] +media = "(prefers-color-scheme: dark)" +scheme = "slate" +primary = "black" +accent = "green" +toggle.icon = "lucide/moon" +toggle.name = "Switch to light mode" + +[[project.theme.palette]] +media = "(prefers-color-scheme: light)" +scheme = "default" +primary = "indigo" +accent = "green" +toggle.icon = "lucide/sun" +toggle.name = "Switch to system preference" + +[project.theme.icon] +repo = "fontawesome/brands/github" + +[project.markdown_extensions.toc] +permalink = true + +[project.markdown_extensions.attr_list] +[project.markdown_extensions.admonition] +[project.markdown_extensions.md_in_html] +[project.markdown_extensions.pymdownx.details] +[project.markdown_extensions.pymdownx.superfences] + +[[project.extra.social]] +icon = "fontawesome/brands/discord" +link = "https://discord.gg/jedJWCPAhD" +name = "PSModule on Discord" + +[[project.extra.social]] +icon = "fontawesome/brands/github" +link = "https://github.com/PSModule/" +name = "PSModule on GitHub" + +[project.extra.consent] +title = "Cookie consent" +description = "We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better." +actions = ["accept", "reject"]