@@ -67,6 +67,10 @@ protected override void Initialize()
67
67
68
68
this . SetRequestHandler ( ShowOnlineHelpRequest . Type , this . HandleShowOnlineHelpRequest ) ;
69
69
this . SetRequestHandler ( ExpandAliasRequest . Type , this . HandleExpandAliasRequest ) ;
70
+
71
+ this . SetRequestHandler ( FindModuleRequest . Type , this . HandleFindModuleRequest ) ;
72
+ this . SetRequestHandler ( InstallModuleRequest . Type , this . HandleInstallModuleRequest ) ;
73
+
70
74
this . SetEventHandler ( CompleteChoicePromptNotification . Type , this . HandleCompleteChoicePromptNotification ) ;
71
75
72
76
this . SetRequestHandler ( DebugAdapterMessages . EvaluateRequest . Type , this . HandleEvaluateRequest ) ;
@@ -128,12 +132,28 @@ protected async Task HandleShowOnlineHelpRequest(
128
132
psCommand . AddArgument ( helpParams ) ;
129
133
psCommand . AddParameter ( "Online" ) ;
130
134
131
- await editorSession . PowerShellContext . ExecuteCommand < object > (
132
- psCommand ) ;
135
+ await editorSession . PowerShellContext . ExecuteCommand < object > ( psCommand ) ;
136
+
137
+ await requestContext . SendResult ( null ) ;
138
+ }
139
+
140
+ private async Task HandleInstallModuleRequest (
141
+ string moduleName ,
142
+ RequestContext < object > requestContext
143
+ )
144
+ {
145
+ var script = string . Format ( "Install-Module -Name {0} -Scope CurrentUser" , moduleName ) ;
146
+
147
+ var executeTask =
148
+ editorSession . PowerShellContext . ExecuteScriptString (
149
+ script ,
150
+ true ,
151
+ true ) . ConfigureAwait ( false ) ;
133
152
134
153
await requestContext . SendResult ( null ) ;
135
154
}
136
155
156
+
137
157
private async Task HandleExpandAliasRequest (
138
158
string content ,
139
159
RequestContext < string > requestContext )
@@ -172,6 +192,28 @@ Sort Start -Descending
172
192
await requestContext . SendResult ( result . First ( ) . ToString ( ) ) ;
173
193
}
174
194
195
+ private async Task HandleFindModuleRequest (
196
+ object param ,
197
+ RequestContext < object > requestContext )
198
+ {
199
+ var psCommand = new PSCommand ( ) ;
200
+ psCommand . AddScript ( "Find-Module | Select Name, Description" ) ;
201
+
202
+ var modules = await editorSession . PowerShellContext . ExecuteCommand < PSObject > ( psCommand ) ;
203
+
204
+ var moduleList = new List < PSModuleMessage > ( ) ;
205
+
206
+ if ( modules != null )
207
+ {
208
+ foreach ( dynamic m in modules )
209
+ {
210
+ moduleList . Add ( new PSModuleMessage { Name = m . Name , Description = m . Description } ) ;
211
+ }
212
+ }
213
+
214
+ await requestContext . SendResult ( moduleList ) ;
215
+ }
216
+
175
217
protected Task HandleCompleteChoicePromptNotification (
176
218
CompleteChoicePromptNotification completeChoicePromptParams ,
177
219
EventContext eventContext )
0 commit comments