Skip to content

Commit 2af4ca6

Browse files
committed
Add argument completer for psake tasks
1 parent 89f30c2 commit 2af4ca6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

build.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
param(
33
# Build task(s) to execute
44
[parameter(ParameterSetName = 'task', position = 0)]
5+
[ArgumentCompleter( {
6+
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams)
7+
$psakeFile = './psakeFile.ps1'
8+
switch ($Parameter) {
9+
'Task' {
10+
if ([string]::IsNullOrEmpty($WordToComplete)) {
11+
Get-PSakeScriptTasks -buildFile $psakeFile | Select-Object -ExpandProperty Name
12+
}
13+
else {
14+
Get-PSakeScriptTasks -buildFile $psakeFile |
15+
Where-Object { $_.Name -match $WordToComplete } |
16+
Select-Object -ExpandProperty Name
17+
}
18+
}
19+
Default {
20+
}
21+
}
22+
})]
523
[string[]]$Task = 'default',
624

725
# Bootstrap dependencies

0 commit comments

Comments
 (0)