Skip to content

Commit adfcf41

Browse files
committed
Initial commit for PS Gallery
1 parent e318640 commit adfcf41

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./"
3939
},
4040
"contributes": {
41-
"keybindings": [
41+
"keybindings": [
4242
{
4343
"command": "PowerShell.OnlineHelp",
4444
"key": "ctrl+f1",
@@ -51,6 +51,11 @@
5151
}
5252
],
5353
"commands": [
54+
{
55+
"command": "PowerShell.FindModule",
56+
"title": "Install PowerShell Module",
57+
"category": "PowerShell"
58+
},
5459
{
5560
"command": "PowerShell.OnlineHelp",
5661
"title": "Get online help for command",

src/features/FindModule.ts

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

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import settingsManager = require('./settings');
1010
import { LanguageClient, LanguageClientOptions, Executable } from 'vscode-languageclient';
1111

1212
import { RequestType, NotificationType, ResponseError } from 'vscode-jsonrpc';
13+
import { registerFindModuleCommand } from './features/FindModule';
1314
import { registerShowHelpCommand } from './features/ShowOnlineHelp';
1415
import { registerConsoleCommands } from './features/Console';
1516

@@ -95,6 +96,7 @@ export function activate(context: vscode.ExtensionContext): void {
9596
client.start();
9697

9798
// Register other features
99+
registerFindModuleCommand(client);
98100
registerShowHelpCommand(client);
99101
registerConsoleCommands(client);
100102
}

0 commit comments

Comments
 (0)