Created
November 28, 2016 15:28
-
-
Save DexterPOSH/757495119ef7f2ea93852c2b2c103758 to your computer and use it in GitHub Desktop.
Try to create tab completion for the PSDeploy DSL.
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
Function PSDeployCompletion | |
{ | |
param( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter) | |
$CommandTree = Get-CompletionPrivateData -Key PSDeployCompletionCommandTree | |
if ($null -eq $CommandTree) { | |
$CommandTree = & { | |
New-CommandTree -Completion FromSource -ToolTip 'Source' -Argument | |
New-CommandTree -Completion To -ToolTip 'Destination' -Argument | |
New-CommandTree -Completion Tagged -ToolTip 'Tags to use for the deployment' -Argument | |
New-CommandTree -Completion WithOptions -ToolTip 'options for the deployment' -SubCommands { | |
New-CommandTree -Completion Test -tooltip 'test' | |
} | |
} | |
Set-CompletionPrivateData -Key PSDeployCompletionCommandTree -Value $commandTree | |
} | |
Get-CommandTreeCompletion $wordToComplete $commandAst $commandTree | |
} | |
Register-ArgumentCompleter ` | |
-Command 'By' ` | |
-ParameterName 'ScriptBlock' ` | |
-Description 'Complete arguments to a Deployment' ` | |
-ScriptBlock $function:PSDeployCompletion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment