-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcompletions.ps1
More file actions
26 lines (22 loc) · 854 Bytes
/
completions.ps1
File metadata and controls
26 lines (22 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@('npm', 'npm.cmd') | ForEach-Object {
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
. "$PSScriptRoot/commands/__.ps1"
. "$PSScriptRoot/lib/__.ps1"
. "$PSScriptRoot/utils.ps1"
$completions = [System.Management.Automation.CompletionResult[]] @()
$1stPart = Get-1stPart $commandAst;
$2ndPart = Get-2ndPart $commandAst;
$3rdPart = Get-3rdPart $commandAst;
if (Compare-CommandElement $1stPart $wordToComplete) {
$completions += Get-1stCompletions $wordToComplete
}
elseif (Compare-CommandElement $2ndPart $wordToComplete) {
$completions += Get-2ndCompletions $wordToComplete $1stPart
}
elseif (Compare-CommandElement $3rdPart $wordToComplete) {
$completions += Get-3rdCompletions $wordToComplete $1stPart $2ndPart
}
return $completions
}
}