private/Split-WpcArgs.ps1

function Split-WpcArgs {
    param([string] $argsStr)

    $result = [System.Collections.Generic.List[string]]::new()
    $argsStr = $argsStr.Trim()
    if ([string]::IsNullOrWhiteSpace($argsStr)) { return @() }

    $current = [System.Text.StringBuilder]::new()
    $inQuote = $false
    $quoteChar = [char]0

    for ($i = 0; $i -lt $argsStr.Length; $i++) {
        $c = $argsStr[$i]

        if (-not $inQuote) {
            if ($c -eq "'" -or $c -eq '"') {
                $inQuote = $true
                $quoteChar = $c
            } elseif ($c -eq ',') {
                $val = $current.ToString().Trim()
                $result.Add($val)
                $current.Clear() | Out-Null
            } else {
                $current.Append($c) | Out-Null
            }
        } else {
            if ($c -eq $quoteChar) {
                $inQuote = $false
                $quoteChar = [char]0
            } else {
                $current.Append($c) | Out-Null
            }
        }
    }

    $val = $current.ToString().Trim()
    if (-not [string]::IsNullOrEmpty($val)) { $result.Add($val) }

    return @($result)
}