Created
January 6, 2017 16:04
-
-
Save mattmcnabb/5e4765779fa17c97ed79eefde8f3755d to your computer and use it in GitHub Desktop.
Tab completion with argument completers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set up a test command | |
function Test-MyCompleter { | |
param | |
( | |
[string[]] | |
$Param1 | |
) | |
} | |
# register the completer | |
$ScriptBlock = { | |
$List = 'aaaaaa','bbbbbb','cccccc' | |
foreach ($Item in $List) | |
{ | |
New-CompletionResult -CompletionText $Item -ToolTip $Item -ListItemText $Item -CompletionResultType ParameterValue | |
} | |
} | |
TabExpansionPlusPlus\Register-ArgumentCompleter -CommandName Test-MyCompleter -ParameterName Param1 -ScriptBlock $ScriptBlock | |
# when I type this and press tab, completion should only offer 'bbbbbb' | |
Test-MyCompleter -Param1 b <TAB> | |
# however, it tab-completes through the list at the first index and I get | |
Test-MyCompleter -Param1 aaaaaa |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment