-
Notifications
You must be signed in to change notification settings - Fork 61
/
TabExpansions.ps1
275 lines (214 loc) · 17.8 KB
/
TabExpansions.ps1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
$computerNameCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$global:RabbitMQServers
}
$virtualHostCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
Get-RabbitMQVirtualHost @parms | where name -like "$wordToComplete*" | select name | ForEach-Object {
$vhname = @{$true="Default"; $false= $_.name}[$_.name -eq "/"]
$cname = @{$true="localhost"; $false = $fakeBoundParameter.ComputerName}[$fakeBoundParameter.ComputerName -eq $null]
$tooltip = "$vhname on $cname."
createCompletionResult $_.name $_.name $tooltip
}
}
$exchangeCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.VirtualHost) { $parms.Add("VirtualHost", $fakeBoundParameter.VirtualHost) }
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
Get-RabbitMQExchange @parms | where name -like "$wordToComplete*" | select name | ForEach-Object {
$ename = @{$true="(AMQP default)"; $false=$_.name}[$_.name -eq ""]
$vhname = @{$true="[default]"; $false= $fakeBoundParameter.VirtualHost}[$fakeBoundParameter.VirtualHost -eq "/"]
$cname = @{$true="localhost"; $false = $fakeBoundParameter.ComputerName}[$fakeBoundParameter.ComputerName -eq $null]
$tooltip = "$ename on $cname/$vhname."
createCompletionResult $ename $ename $tooltip
}
}
$connectionCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
Get-RabbitMQConnection @parms | where name -like "$wordToComplete*" | select name | ForEach-Object {
$cname = @{$true="localhost"; $false = $fakeBoundParameter.ComputerName}[$fakeBoundParameter.ComputerName -eq $null]
$tooltip = "$_.name on $cname."
createCompletionResult $_.name $_.name $tooltip
}
}
$nodeCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
Get-RabbitMQNode @parms | where name -like "$wordToComplete*" | select name | ForEach-Object {
$cname = @{$true="localhost"; $false = $fakeBoundParameter.ComputerName}[$fakeBoundParameter.ComputerName -eq $null]
$tooltip = $_.name + " on " + $cname + "."
createCompletionResult $_.name $_.name $tooltip
}
}
$channelCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.VirtualHost) { $parms.Add("VirtualHost", $fakeBoundParameter.VirtualHost) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
Get-RabbitMQChannel @parms | where name -like "$wordToComplete*" | select name | ForEach-Object {
$cname = @{$true="localhost"; $false = $fakeBoundParameter.ComputerName}[$fakeBoundParameter.ComputerName -eq $null]
$tooltip = $_.name + " on " + $cname + "."
createCompletionResult $_.name $_.name $tooltip
}
}
$queueCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.VirtualHost) { $parms.Add("VirtualHost", $fakeBoundParameter.VirtualHost) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
Get-RabbitMQQueue @parms | where name -like "$wordToComplete*" | ForEach-Object {
$cname = @{$true="localhost"; $false = $fakeBoundParameter.ComputerName}[$fakeBoundParameter.ComputerName -eq $null]
$n = "$($_.name) ($($_.messages))"
$tooltip = "$($_.name) on $cname/$($_.vhost) ($($_.messages) messages)."
createCompletionResult $n $_.name $tooltip
}
}
$routingKeyGeneration_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.VirtualHost) { $parms.Add("VirtualHost", $fakeBoundParameter.VirtualHost) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
$tooltip = "Bind exchange " + $fakeBoundParameter.ExchangeName + " to queue " + $fakeBoundParameter.Name + "."
createCompletionResult $fakeBoundParameter.Name $tooltip
createCompletionResult $($fakeBoundParameter.ExchangeName + "-" + $fakeBoundParameter.Name) $tooltip
createCompletionResult $($fakeBoundParameter.ExchangeName + "->" + $fakeBoundParameter.Name) $tooltip
createCompletionResult $($fakeBoundParameter.ExchangeName + ".." + $fakeBoundParameter.Name) $tooltip
}
$routingKeyCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.VirtualHost) { $parms.Add("VirtualHost", $fakeBoundParameter.VirtualHost) }
#if ($fakeBoundParameter.ExchangeName) { $parms.Add("ExchangeName", $fakeBoundParameter.ExchangeName) }
if ($fakeBoundParameter.Name) { $parms.Add("Name", $fakeBoundParameter.Name) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
#Get-RabbitMQQueueBinding @parms | where name -like "$wordToComplete*" | select routing_key | ForEach-Object {
$a = Get-RabbitMQQueueBinding @parms
$b = $a | where source -eq $fakeBoundParameter.ExchangeName | select routing_key
$b | ForEach-Object {
createCompletionResult $_.routing_key $_.routing_key $_.routing_key
}
}
$userCompletion_Process = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$parms = @{}
if ($fakeBoundParameter.ComputerName) { $parms.Add("ComputerName", $fakeBoundParameter.ComputerName) }
if ($fakeBoundParameter.Credentials) { $parms.Add("Credentials", $fakeBoundParameter.Credentials) }
if ($fakeBoundParameter.UserName) { $parms.Add("UserName", $fakeBoundParameter.UserName) }
if ($fakeBoundParameter.Password) { $parms.Add("Password", $fakeBoundParameter.Password) }
Get-RabbitMQUser @parms | where name -like "$wordToComplete*" | ForEach-Object {
$tooltip = "$($_.name) [$($_.tags)]"
createCompletionResult $_.name $_.name $tooltip
}
}
function createCompletionResult([string]$text, [string]$value, [string]$tooltip) {
if ([string]::IsNullOrEmpty($value)) { return }
if ([string]::IsNullOrEmpty($text)) { $text = $value }
if ([string]::IsNullOrEmpty($tooltip)) { $tooltip = $value }
$completionText = @{$true="'$value'"; $false=$value }[$value -match "\W"]
$completionText = $completionText -replace '\[', '``[' -replace '\]', '``]'
return New-Object System.Management.Automation.CompletionResult $completionText, $text, 'ParameterValue', $tooltip
}
if (-not $global:options) { $global:options = @{CustomArgumentCompleters = @{};NativeArgumentCompleters = @{}}}
$global:options['CustomArgumentCompleters']['Test1:Name'] = $testCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQOverview:Name'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQVirtualHost:Name'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQVirtualHost:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQVirtualHost:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQVirtualHost:Name'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQVirtualHost:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQExchange:Name'] = $exchangeCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQExchange:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQExchange:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQExchange:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQExchange:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQExchange:Name'] = $exchangeCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQExchange:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQExchange:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQConnection:Name'] = $connectionCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQConnection:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQConnection:Name'] = $connectionCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQConnection:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQNode:Name'] = $nodeCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQNode:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQChannel:Name'] = $channelCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQChannel:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQChannel:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQQueue:Name'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQQueue:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQQueue:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQQueue:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQQueue:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueue:Name'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueue:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueue:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQQueueBinding:Name'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQQueueBinding:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQQueueBinding:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQQueueBinding:Name'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQQueueBinding:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQQueueBinding:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQQueueBinding:ExchangeName'] = $exchangeCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQQueueBinding:RoutingKey'] = $routingKeyGeneration_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueueBinding:Name'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueueBinding:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueueBinding:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueueBinding:ExchangeName'] = $exchangeCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQQueueBinding:RoutingKey'] = $routingKeyCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQMessage:Name'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQMessage:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQMessage:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Clear-RabbitMQQueue:Name'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Clear-RabbitMQQueue:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Clear-RabbitMQQueue:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Copy-RabbitMQMessage:SourceQueueName'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Copy-RabbitMQMessage:DestinationQueueName'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Copy-RabbitMQMessage:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Copy-RabbitMQMessage:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Move-RabbitMQMessage:SourceQueueName'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Move-RabbitMQMessage:DestinationQueueName'] = $queueCompletion_Process
$global:options['CustomArgumentCompleters']['Move-RabbitMQMessage:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Move-RabbitMQMessage:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQUser:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQUser:Name'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQUser:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQUser:Name'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Set-RabbitMQUser:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Set-RabbitMQUser:Name'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQUser:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQUser:Name'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQPermission:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQPermission:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Get-RabbitMQPermission:User'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQPermission:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQPermission:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Add-RabbitMQPermission:User'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Set-RabbitMQPermission:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Set-RabbitMQPermission:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Set-RabbitMQPermission:User'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQPermission:ComputerName'] = $computerNameCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQPermission:VirtualHost'] = $virtualHostCompletion_Process
$global:options['CustomArgumentCompleters']['Remove-RabbitMQPermission:User'] = $userCompletion_Process
$global:options['CustomArgumentCompleters']['Unregister-RabbitMQServer:ComputerName'] = $computerNameCompletion_Process
$function:tabexpansion2 = $function:tabexpansion2 -replace 'End\r\n{','End { if ($null -ne $options) { $options += $global:options} else {$options = $global:options}'