-
-
Notifications
You must be signed in to change notification settings - Fork 60
Argument Completers
PowerShell provides powerful code completion tools and extensions. One of the useful features is custom argument completers.
The script Invoke-Build.ArgumentCompleters.ps1 registers Invoke-Build
completers. You may install it from PSGallery (included to the path
automatically but may require a fresh session):
Install-Script Invoke-Build.ArgumentCompleters
or download and choose your own location, consider included to the path:
Save-Script Invoke-Build.ArgumentCompleters -Path .
Completers are defined for two Invoke-Build
parameters:
-
Task
- Task names are completed from the default or specified build script. -
File
- For**
gets directories otherwise directories and .ps1 files.
Note that completion of dynamic parameters coming from a build script also works, with or without custom completers. This feature is built-in.
Invoke installed or downloaded completers, e.g. in your PowerShell profile
(see the variable $PROFILE
):
Invoke-Build.ArgumentCompleters.ps1
Use TabExpansion2.ps1 as the extension of the native completion engine, with some handy features.
Put Invoke-Build.ArgumentCompleters.ps1
to the path in order to be loaded
automatically on the first completion.
For even better completion experience in the console you may use GuiCompletion.
(Not just for Invoke-Build, any PowerShell code completion.)
Install the module from PSGallery by this command:
Install-Module GuiCompletion
Then enable it in PowerShell sessions, for example in your profile (see the variable $PROFILE
):
Install-GuiCompletion # with the default `Ctrl+Spacebar`
Install-GuiCompletion -Key Tab # with the traditional `Tab`
This is recommended for all build scripts but especially for scripts designed for task name completion and other introspections.
Any significant script level code should be wrapped by Enter-Build {...}
or
if (!$WhatIf) {...}
. Otherwise the code is invoked on task name completion
and commands like Invoke-Build ?
and Invoke-Build -WhatIf
may have not
desired effects.
- Concepts
- Script Tutorial
- Incremental Tasks
- Partial Incremental Tasks
- How Build Works
- Special Variables
- Build Failures
- Build Analysis
- Parallel Builds
- Persistent Builds
- Portable Build Scripts
- Using for Test Automation
- Debugging Tips
- VSCode Tips
Helpers
- Invoke Task from VSCode
- Generate VSCode Tasks
- Invoke Task from ISE
- Resolve MSBuild
- Show Build Trees
- Show Build Graph
- Argument Completers
- Invoke-Build.template
Appendix