This is a script for VS PowerShell.
function global:Add-Shape { param([string]$Shape, [string[]]$Colors)
Write-Host "Shape Name:$Shape"
foreach ($i in $Colors) {
Write-Host "Color Name:$i"
}
}
Register-TabExpansion 'Add-Shape' @{
'Shape' = {
"Circle",
"Square",
"Triangle"
}
'Colors' = {
"Brown",
"Red",
"Blue"
}
}
In Package Manager Console When I try this command to run the script and I can use tab to select options and then values for each option from TabExpansion:
Add-Shape -Shape Circle -Colors Red,...
The problem is after selecting first value for array option tab completion never shows again to select additional.
you can use ValidateSet:
function global:Add-Shape {
param(
[ValidateSet("Circle","Square","Triangle")]
[string]$Shape,
[ValidateSet("Brown","Red","Blue")]
[string[]]$Colors
)
Write-Host "Shape Name:$Shape"
foreach ($i in $Colors) {
Write-Host "Color Name:$i"
}
}