Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c178a73
Implement Toml module with full TOML 1.0.0 support
MariusStorhaug Jul 19, 2026
1c52086
Merge origin/main into build-toml-module
MariusStorhaug Jul 23, 2026
dc1d3ba
feat!: Pure PowerShell TOML 1.0.0 module β€” full parser, serializer, a…
MariusStorhaug Jul 23, 2026
2d14f86
docs: Add .LINK to all public function comment-based help
MariusStorhaug Jul 23, 2026
5ee6f97
refactor: Move functions to flat public/private layout, clean README
MariusStorhaug Jul 23, 2026
f9d70da
refactor: Remove obsolete src scaffolding files
MariusStorhaug Jul 23, 2026
19e20a5
test: Consolidate all tests into single Toml.Tests.ps1
MariusStorhaug Jul 23, 2026
6af7f93
chore: Restore zensical.toml to .github/
MariusStorhaug Jul 23, 2026
9f42c39
chore: Remove mkdocs.yml replaced by zensical.toml
MariusStorhaug Jul 23, 2026
a6a32c7
style: Align with MSXOrg and PSModule coding standards
MariusStorhaug Jul 24, 2026
ab48673
🩹 [Patch]: Add Test-Toml to validate TOML without throwing (#22)
MariusStorhaug Jul 26, 2026
2ea9455
πŸš€ [Feature]: Merge-Toml combines TOML documents into one (#21)
MariusStorhaug Jul 26, 2026
8e594b1
πŸš€ [Minor]: Format-Toml normalizes TOML to canonical form (#20)
MariusStorhaug Jul 26, 2026
4c774e3
Fix CI failures: UTF-8 BOM on all PS1 files, class exporter block, li…
MariusStorhaug Jul 26, 2026
88777b7
Fix PSUseOutputTypeCorrectly and PSUseConsistentIndentation lint viol…
MariusStorhaug Jul 26, 2026
79bcfff
Fix PSAvoidLongLines and revert broken ToArray overload in Split-Toml…
MariusStorhaug Jul 26, 2026
fac67cc
fix: add TomlValueKind enum and resolve remaining lint violations
MariusStorhaug Jul 26, 2026
5b804ad
fix: resolve Lint-Repository and Build-Docs failures
MariusStorhaug Jul 26, 2026
b6900c0
fix: add mkdocs.yml template for Build-Site
MariusStorhaug Jul 26, 2026
c39e33f
Upgrade Process-PSModule to v6.1.14 and align site/help links
MariusStorhaug Jul 26, 2026
c41ac1b
Align build script with Process-PSModule v6 version stamping
MariusStorhaug Jul 26, 2026
b77396c
Update Process-PSModule to v6.1.15
MariusStorhaug Aug 3, 2026
f3696fa
docs: Add CONTRIBUTING.md to fix README link
MariusStorhaug Aug 3, 2026
c03c68b
refactor: Align repository layout with PSModule standards
MariusStorhaug Aug 3, 2026
a803b4a
test: Add Pester 6 requirement to test file
MariusStorhaug Aug 3, 2026
e9f7fb3
test(fixtures): make test fixture arrays valid TOML 1.0.0
MariusStorhaug Aug 3, 2026
3c954e3
test+fix: add production edge-case coverage and fix exposed bugs
MariusStorhaug Aug 3, 2026
5260b1b
style: fix PSScriptAnalyzer indentation/alignment warning in string e…
MariusStorhaug Aug 3, 2026
09fcdda
style: declare object[] OutputType for ConvertFrom-TomlValue
MariusStorhaug Aug 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/PSModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Linter:
VALIDATE_JSCPD: false
VALIDATE_JSON_PRETTIER: false
VALIDATE_MARKDOWN_PRETTIER: false
VALIDATE_YAML: false
VALIDATE_YAML_PRETTIER: false
4 changes: 2 additions & 2 deletions .github/workflows/Process-PSModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ permissions:

jobs:
Process-PSModule:
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@fb1bdb8fefd243292f779d2a856a38db6fe6daf4 # v6.1.13
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@688896dc3ef70fb35bd74ae5328e76d5e57fe08a # v6.1.15
secrets:
APIKEY: ${{ secrets.APIKEY }}
APIKey: ${{ secrets.APIKey || secrets.APIKEY }}
File renamed without changes.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@

# PSModule framework outputs folder
outputs/*
output/

# .Net build output
bin/
obj/
libs/

# Pester test output
testResults.xml
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing to Toml

Thank you for your interest in improving the Toml module!

## Reporting issues

If you find a bug, have a feature request, or notice something unclear in the documentation, please open an issue in the [issue tracker](https://github.com/PSModule/Toml/issues).

Include as much detail as possible, such as:

- The version of the module you are using.
- The version of PowerShell you are running (`$PSVersionTable`).
- A minimal TOML snippet or script that reproduces the issue.
- The expected behavior and the actual behavior.

## Submitting changes

1. Fork the repository and create a feature branch from `main`.
2. Make focused, well-scoped changes.
3. Add or update tests in `tests/` for any changed behavior.
4. Run the local build and test suite:

```powershell
pwsh -File .\build.ps1
Import-Module .\output\Toml\Toml.psd1 -Force
Invoke-Pester -Path .\tests\Toml.Tests.ps1
```

5. Ensure `PSScriptAnalyzer` reports no errors or warnings:

```powershell
Invoke-ScriptAnalyzer -Path .\src -Recurse -Severity Error,Warning
```

6. Open a pull request with a clear description of the change and the problem it solves.

## Coding conventions

- Follow the existing file and folder structure under `src/`.
- Keep functions small and focused.
- Use `[ordered]` hashtables where key order matters.
- Add comment-based help to public functions.
- Write Pester tests for public commands and parser edge cases.

## Code of conduct

Be respectful and constructive. We welcome contributors of all experience levels.
163 changes: 153 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,174 @@
# Toml

Toml is a PowerShell module for reading TOML file content from disk so scripts can load and process configuration text.
PowerShell module for reading and writing [TOML](https://toml.io) data, with full TOML 1.0.0 specification support.

## Prerequisites

- PowerShell 7.6 LTS
- The [PSModule framework](https://github.com/PSModule/Process-PSModule) for building, testing and publishing the module.

## Installation

Install the module from the PowerShell Gallery:
To install the module from the PowerShell Gallery, you can use the following command:

```powershell
Install-PSResource -Name Toml
Import-Module -Name Toml
```

## Capabilities
## Usage

Use this command to read TOML content from a file path:
### Parse a TOML string

```powershell
Get-Toml -Path '.\settings.toml'
$doc = ConvertFrom-Toml -InputObject @'
[database]
host = "localhost"
port = 5432
enabled = true
'@

$doc.Data.database.host # "localhost"
$doc.Data.database.port # 5432 [long]
$doc.Data.database.enabled # $true
```

## Documentation
### Import from a TOML file

```powershell
$doc = Import-Toml -Path './config.toml'
$doc.FilePath # absolute path to the file
$doc.Data # OrderedDictionary of all top-level keys
```

### Serialize an object to TOML

```powershell
$toml = ConvertTo-Toml -InputObject ([ordered]@{
title = 'My App'
version = 1
server = [ordered]@{
host = 'localhost'
port = 8080
}
})
# title = "My App"
# version = 1
#
# [server]
# host = "localhost"
# port = 8080
```

### Export to a TOML file

```powershell
$config = [ordered]@{
name = 'example'
enabled = $true
}
Export-Toml -InputObject $config -Path './output.toml'
```

### Round-trip: file β†’ modify β†’ file

```powershell
$doc = Import-Toml -Path './config.toml'
$doc.Data['version'] = 2
Export-Toml -InputObject $doc -Path './config.toml'
```

### Normalize TOML text

```powershell
Get-Content 'Cargo.toml' -Raw | Format-Toml
Format-Toml -Path 'Cargo.toml' -Indent 4
```

Documentation is published at [psmodule.io/Toml](https://psmodule.io/Toml/).
`Format-Toml` parses then re-serializes TOML text, producing consistent key
quoting and canonical scalar forms β€” equivalent to
`ConvertFrom-Toml | ConvertTo-Toml` as a single call. TOML itself has no
indentation semantics; `-Indent` (default `2`) only controls how many spaces
are used to visually nest table headers and their keys by depth. Set
`-Indent 0` for the flat, unindented form.

Use PowerShell help and command discovery for details:
### Merge two TOML documents

```powershell
Get-Command -Module Toml
Get-Help -Name Get-Toml -Examples
$defaults = @'
[server]
host = "localhost"
port = 8080
'@

$overrides = @'
[server]
port = 9090
'@

Merge-Toml -BaseObject $defaults -OverrideObject $overrides
# [server]
# host = "localhost"
# port = 9090
```

`Merge-Toml` also accepts `-Path`/`-LiteralPath` for merging files, and a `-Strategy` of `LastWins` (default), `FirstWins`, or `ErrorOnConflict` for resolving scalar key conflicts. Nested tables are always deep-merged and arrays of tables are always concatenated.

## TOML type mapping

| TOML type | PowerShell type |
|----------------------|----------------------------|
| String | `[string]` |
| Integer | `[long]` |
| Float | `[double]` |
| Boolean | `[bool]` |
| Offset date-time | `[System.DateTimeOffset]` |
| Local date-time | `[System.DateTime]` |
| Local date | `[System.DateTime]` |
| Local time | `[System.TimeSpan]` |
| Array | `[object[]]` |
| Table / Inline table | `[ordered]` hashtable |
| Array of tables | `[object[]]` of hashtables |

## Commands

| Command | Description |
|---------------------|------------------------------------------|
| `ConvertFrom-Toml` | Parse TOML text β†’ `TomlDocument` |
| `ConvertTo-Toml` | Serialize object β†’ TOML text |
| `Import-Toml` | Read TOML file β†’ `TomlDocument` |
| `Export-Toml` | Write object or `TomlDocument` to file |
| `Format-Toml` | Normalize TOML text to canonical form |
| `Test-Toml` | Validate TOML text without throwing |
| `Merge-Toml` | Merge two TOML documents into one |

## Implementation notes

- Pure PowerShell parser and serializer β€” no external TOML runtime dependency.
- Duplicate keys and table redefinition are rejected per the TOML 1.0.0 spec.
- Files are written as UTF-8 without BOM.

## More examples

See the [examples](examples) folder for runnable scripts. Use PowerShell help for per-command examples:

```powershell
Get-Help ConvertFrom-Toml -Examples
Get-Help Import-Toml -Examples
```

## Documentation

Full documentation is available at [psmodule.io/Toml](https://psmodule.io/Toml).

## Contributing

Coder or not, you can contribute to the project! We welcome all contributions.

### For Users

If you experience unexpected behavior, errors, or missing functionality, please open an issue on the [issues tab](https://github.com/PSModule/Toml/issues).

### For Developers

Please read the [Contribution guidelines](CONTRIBUTING.md) and pick up an existing issue or submit a new one.
Loading
Loading