Last active
July 18, 2021 10:43
-
-
Save krymtkts/b2e6742691fdca6ca09567ca146063df to your computer and use it in GitHub Desktop.
This is Register-ArgumentCompleter version of https://github.com/psake/psake/blob/master/tabexpansion/PsakeTabExpansion.ps1.
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
$psake = Get-Command -Name Invoke-psake -ErrorAction SilentlyContinue | |
if ($psake) { | |
Register-ArgumentCompleter -Native -CommandName $psake.Name -ScriptBlock { | |
param($wordToComplete, $commandAst, $cursorPosition) | |
Get-ChildItem "$wordToComplete*.ps1" | Select-Object -ExpandProperty Name | |
} | |
Register-ArgumentCompleter -CommandName $psake.Name -ParameterName taskList -ScriptBlock { | |
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters) | |
if ($commandAst -match '(?<file>[^\.]*\.ps1)') { | |
$file = $Matches.file | |
} | |
else { | |
$file = 'psakefile.ps1' | |
} | |
& $commandName -buildFile $file -docs -nologo | Out-String -Stream | ForEach-Object { if ($_ -match "^[^ ]*") { $matches[0] } } | ` | |
Where-Object { $_ -notin ('Name', '----', '') } | Where-Object { !$wordToComplete -or $_ -like "$wordToComplete*" } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment