-
-
Notifications
You must be signed in to change notification settings - Fork 59
Argument Completers
PowerShell v3+ provides powerful code completion tools and ability to customize and extend them even though official guidelines are seemingly missing. The most useful feature is custom argument completers.
The script Invoke-Build.ArgumentCompleters.ps1 registers Invoke-Build completers. In PowerShell v5 it can be installed to the path from PSGallery:
Install-Script Invoke-Build.ArgumentCompleters
or downloaded:
Save-Script Invoke-Build.ArgumentCompleters -Path .
Completers are defined for two parameters:
-
Task
- Task names are completed from the default or specified build script. -
File
- For**
gets directories otherwise directories and .ps1 files.
Note that it is possible to complete Invoke-Build dynamic parameters which come from a build script, the default or specified. This feature is built-in and it should work right away without custom tools.
Simply invoke Invoke-Build.ArgumentCompleters.ps1
, e.g. in a profile.
TabExpansionPlusPlus (module)
Put Invoke-Build.ArgumentCompleters.ps1
to the TabExpansionPlusPlus module
directory in order to be loaded automatically. Or invoke it after importing
the module, e.g. in a profile.
TabExpansion2.ps1 (script)
Put Invoke-Build.ArgumentCompleters.ps1
to the path in order to be loaded
automatically on the first completion. Or invoke after TabExpansion2.ps1
,
e.g. in a profile.
This is recommended for all build scripts and especially for scripts designed
for task name completion. If a build script does anything significant before
invoking tasks then this code should be wrapped by if (!$WhatIf) {...}
or
Enter-Build {...}
. Otherwise it is invoked on task name completion, getting
task info (Invoke-Build ?
), showing code (Invoke-Build -WhatIf
), and other
similar scenarios.
- 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