Skip to content

Instantly share code, notes, and snippets.

@DexterPOSH
Created November 28, 2016 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DexterPOSH/757495119ef7f2ea93852c2b2c103758 to your computer and use it in GitHub Desktop.
Save DexterPOSH/757495119ef7f2ea93852c2b2c103758 to your computer and use it in GitHub Desktop.
Try to create tab completion for the PSDeploy DSL.
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