Skip to content
Browse files

Update tab support to handle task calling without the -task switch

  • Loading branch information...
1 parent b151386 commit e724e28d260f7fc2650be938114bdd2d70e9e467 Dusty Candland committed with stej
Showing with 18 additions and 10 deletions.
  1. +18 −10 tabexpansion/PsakeTabExpansion.ps1
View
28 tabexpansion/PsakeTabExpansion.ps1
@@ -1,23 +1,31 @@
-$global:psakeSwitches = '-docs', '-task', '-properties', '-parameters'
+$global:psakeSwitches = @('-docs', '-task', '-properties', '-parameters')
-function script:psakeSwitches($filter) {
+function script:psakeSwitches($filter) {
$psakeSwitches | where { $_ -like "$filter*" }
}
-function script:psakeDocs($filter) {
- psake -docs | out-string -Stream |% { if ($_ -match "^[^ ]*") { $matches[0]} } |? { $_ -ne "Name" -and $_ -ne "----" -and $_ -like "$filter*" }
+function script:psakeDocs($filter, $file) {
+ if ($file -eq $null -or $file -eq '') { $file = 'default.ps1' }
+ psake $file -docs | out-string -Stream |% { if ($_ -match "^[^ ]*") { $matches[0]} } |? { $_ -ne "Name" -and $_ -ne "----" -and $_ -like "$filter*" }
+}
+
+function script:psakeFiles($filter) {
+ ls "$filter*.ps1" |% { $_.Name }
}
function PsakeTabExpansion($lastBlock) {
switch -regex ($lastBlock) {
- '(invoke-psake|psake) .* ?\-t[^ ]* (\S*)$' {
- psakeDocs $matches[2]
- }
- '(invoke-psake|psake) .* ?(\-\S*)$' {
- psakeSwitches $matches[2]
+ '(invoke-psake|psake) ([^\.]*\.ps1)? ?.* ?\-ta?s?k? (\S*)$' { # tasks only
+ psakeDocs $matches[3] $matches[2] | sort
+ }
+ '(invoke-psake|psake) ([^\.]*\.ps1)? ?.* ?(\-\S*)$' { # switches only
+ psakeSwitches $matches[3] | sort
+ }
+ '(invoke-psake|psake) ([^\.]*\.ps1) ?.* ?(\S*)$' { # switches or tasks
+ @(psakeDocs $matches[3] $matches[2]) + @(psakeSwitches $matches[3]) | sort
}
'(invoke-psake|psake) (\S*)$' {
- ls $matches[2]*.ps1 |% { "./$_" }
+ @(psakeFiles $matches[2]) + @(psakeDocs $matches[2] 'default.ps1') + @(psakeSwitches $matches[2]) | sort
}
}
}

0 comments on commit e724e28

Please sign in to comment.
Something went wrong with that request. Please try again.