File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 2
2
Register-ArgumentCompleter - Native - CommandName $_ - ScriptBlock {
3
3
param ($wordToComplete , $commandAst , $cursorPosition )
4
4
5
- . $PSScriptRoot \commands.ps1
5
+ $subCommand = $commandAst.CommandElements [1 ].Value
6
+
7
+ switch ($subCommand ) {
8
+ ' global' {
9
+ . $PSScriptRoot \sub- commands\global.ps1
10
+ }
11
+ Default {
12
+ . $PSScriptRoot \commands.ps1
13
+
14
+ # Don't complete any word after sub-command when it isn't one of above commands.
15
+ if ($subCommand -in $cmds ) {
16
+ $cmds = @ ()
17
+ }
18
+ }
19
+ }
20
+
6
21
$cmds |
7
22
Where-Object { $_ -like " $wordToComplete *" } |
8
23
Sort-Object |
Original file line number Diff line number Diff line change
1
+ $cmds = @ (
2
+ ' add' ,
3
+ ' bin' ,
4
+ ' list' ,
5
+ ' remove' ,
6
+ ' upgrade' ,
7
+ ' upgrade-interactive'
8
+ )
You can’t perform that action at this time.
0 commit comments