22 lines
569 B
PowerShell
22 lines
569 B
PowerShell
[CmdletBinding()]param(
|
|
[string]$WordToComplete,
|
|
[string[]]$FullValueSet,
|
|
[switch]$Strict
|
|
)
|
|
$local:possibleValues = $fullValueSet
|
|
if( $wordToComplete ) {
|
|
$possibleValues = $possibleValues |
|
|
Where-Object { $_ -match $wordToComplete } |
|
|
ForEach-Object {
|
|
if( $_ -match ' ' ) {
|
|
"'$_'"
|
|
} else {
|
|
$_
|
|
}
|
|
}
|
|
if( -not $strict -and ($wordToComplete -notin $possibleValues) ) {
|
|
$possibleValues = $( $wordToComplete; $possibleValues )
|
|
}
|
|
}
|
|
return $possibleValues
|