Skip to content

Commit 69d1e16

Browse files
committed
Updated
1 parent 6651a20 commit 69d1e16

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@
6363
"command": "PowerShell.OpenInISE",
6464
"key": "ctrl+alt+i",
6565
"when": "editorTextFocus && editorLangId == 'powershell'"
66+
},
67+
{
68+
"command": "PowerShell.PowerShellFindModule",
69+
"key": "ctrl+p+i",
70+
"when": "editorTextFocus && editorLangId == 'powershell'"
6671
}
72+
6773
],
6874
"commands": [
6975
{
@@ -85,6 +91,11 @@
8591
"command": "PowerShell.OpenInISE",
8692
"title": "Open current file in PowerShell ISE",
8793
"category": "PowerShell"
94+
},
95+
{
96+
"command": "PowerShell.PowerShellFindModule",
97+
"title": "Find/Install PowerShell modules from the gallery",
98+
"category": "PowerShell"
8899
}
89100
],
90101
"snippets": [

src/features/PowerShellFindModule.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import vscode = require('vscode');
2+
import { LanguageClient, RequestType, NotificationType } from 'vscode-languageclient';
3+
import Window = vscode.window;
4+
import QuickPickItem = vscode.QuickPickItem;
5+
6+
export namespace FindModuleRequest {
7+
export const type: RequestType<any, any, void> = { get method() { return 'powerShell/findModule'; } };
8+
}
9+
10+
export function registerPowerShellFindModuleCommand(client: LanguageClient): void {
11+
var disposable = vscode.commands.registerCommand('PowerShell.PowerShellFindModule', () => {
12+
var items: QuickPickItem[] = [];
13+
14+
vscode.window.setStatusBarMessage("Querying PowerShell Gallery", 1500);
15+
16+
client.sendRequest(FindModuleRequest.type, null).then((modules) => {
17+
for(var i=0 ; i < modules.moduleList.length; i++) {
18+
var module = modules.moduleList[i];
19+
items.push({ label: module.name, description: module.description });
20+
}
21+
22+
Window.showQuickPick(items).then((selection) => {
23+
switch (selection.label) {
24+
default :
25+
Window.showInformationMessage("Installing PowerShell Module " + selection.label);
26+
}
27+
});
28+
});
29+
});
30+
}

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { LanguageClient, LanguageClientOptions, Executable, RequestType, Notific
1212
import { registerExpandAliasCommand } from './features/ExpandAlias';
1313
import { registerShowHelpCommand } from './features/ShowOnlineHelp';
1414
import { registerOpenInISECommand } from './features/OpenInISE';
15+
import { registerPowerShellFindModuleCommand } from './features/PowerShellFindModule';
1516
import { registerConsoleCommands } from './features/Console';
1617

1718
var languageServerClient: LanguageClient = undefined;
@@ -101,6 +102,7 @@ export function activate(context: vscode.ExtensionContext): void {
101102
registerShowHelpCommand(languageServerClient);
102103
registerConsoleCommands(languageServerClient);
103104
registerOpenInISECommand();
105+
registerPowerShellFindModuleCommand(languageServerClient);
104106
}
105107

106108
export function deactivate(): void {

0 commit comments

Comments
 (0)