Src/Private/Save-Defaults.ps1

<#
.NOTES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Module: PSPassPhrase
Function: Save-Defaults (PRIVATE)
Author: Martin Cooper (@mc1903)
Date: 20-09-2025
GitHub Repo: https://github.com/mc1903/PSPassPhrase
Version: 1.0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
#>


Function Save-Defaults {
    
    [CmdletBinding()]
        
    Param (
        [int]$passPhraseCount,
        [int]$wordsPerPassPhrase,
        [int]$minWordLength,
        [int]$maxWordLength,
        [string]$delimiterChar,
        [bool]$firstCapitalOnly,
        [int]$randomNumberLength,
        [bool]$noLastSpecialChar,
        [string[]]$specialCharacterList,
        [string]$wordListPath,
        [string]$configPath
    )
    
    $lines = @(
        "passPhraseCount=$passPhraseCount"
        "wordsPerPassPhrase=$wordsPerPassPhrase"
        "minWordLength=$minWordLength"
        "maxWordLength=$maxWordLength"
        "delimiterChar=$delimiterChar"
        "firstCapitalOnly=$firstCapitalOnly"
        "randomNumberLength=$randomNumberLength"
        "noLastSpecialChar=$noLastSpecialChar"
        "specialCharacterList=$($specialCharacterList -join ',')"
        "wordListPath=$wordListPath"
    )
    
    Set-Content -Path $configPath -Value $lines
    Write-Output "Defaults saved to $configPath"
}