Skip to content

Commit

Permalink
PsIni: add -delimiter and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
couleurm committed Jan 8, 2024
1 parent 5c70449 commit fa143f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions helpers/PsInI/Get-IniContent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@
# Lines starting with the characters provided will be rendered as comments.
# Default: ";"
[Char[]]
$CommentChar = @(";"),
$CommentChar = @(";", "#", ":", "/"),

# Remove lines determined to be comments from the resulting dictionary.
[Switch]
$IgnoreComments
$IgnoreComments,

[String]
$delimiter = '='
)

Begin {
Expand All @@ -89,7 +92,7 @@

$commentRegex = "^\s*([$($CommentChar -join '')].*)$"
$sectionRegex = "^\s*\[(.+)\]\s*$"
$keyRegex = "^\s*(.+?)\s*=\s*(['`"]?)(.*)\2\s*$"
$keyRegex = "^\s*(.+?)\s*$delimiter\s*(['`"]?)(.*)\2\s*$"

Write-Debug ("commentRegex is {0}." -f $commentRegex)
}
Expand Down
8 changes: 5 additions & 3 deletions helpers/PsInI/Out-IniFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ Function Out-IniFile {
#
# Adds an extra linebreak between Sections
[Switch]
$Pretty
$Pretty,

[String]
$delimiter = '='
)

Begin {
Expand Down Expand Up @@ -161,9 +164,8 @@ Function Out-IniFile {
}
}

$delimiter = '='
if ($Loose) {
$delimiter = ' = '
$delimiter = "$delimiter "
}

# Splatting Parameters
Expand Down

0 comments on commit fa143f6

Please sign in to comment.