Private/Resolve-Options.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
Function Resolve-Options { [cmdletbinding()] Param( [array]$Arguments ) $Options = @{ globalIsPresent = $false listIsPresent = $false versionIsPresent = $false versionNumberIsValid = $false versionNumber = $null } foreach ($Argument in $Arguments) { switch ($Argument) { { $_ -match '^version$' } { $Options.versionIsPresent = $true Write-Debug "versionIsPresent = true" } { try { [version]$_ }catch {} } { $Options.versionNumberIsValid = $true $Options.versionNumber = $_ Write-Debug "versionNumberIsValid = true" } { $_ -match '^list$' } { $Options.listIsPresent = $true Write-Debug "listIsPresent = true" } { $_ -match '^global$' } { $Options.globalIsPresent = $true Write-Debug "globalIsPresent = true" } } } $Options | ConvertTo-Json | Write-Debug Return $Options } |