Skip to content

Commit 183ff00

Browse files
authored
Merge pull request #172 from jpogran/GH-167-pdk-task
(GH-167) Add PDK New Task
2 parents a99c2ae + 6389e8a commit 183ff00

File tree

4 files changed

+69
-4
lines changed

4 files changed

+69
-4
lines changed

client/package.json

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"onCommand:extension.puppetResource",
4848
"onCommand:extension.pdkNewModule",
4949
"onCommand:extension.pdkNewClass",
50+
"onCommand:extension.pdkNewTask",
5051
"onCommand:extension.pdkTestUnit",
5152
"onCommand:extension.pdkValidate"
5253
],
@@ -128,6 +129,11 @@
128129
"category": "Puppet",
129130
"title": "PDK New Class"
130131
},
132+
{
133+
"command": "extension.pdkNewTask",
134+
"category": "Puppet",
135+
"title": "PDK New Task"
136+
},
131137
{
132138
"command": "extension.puppetResource",
133139
"category": "Puppet",
@@ -163,6 +169,9 @@
163169
{
164170
"command": "extension.pdkNewClass"
165171
},
172+
{
173+
"command": "extension.pdkNewTask"
174+
},
166175
{
167176
"command": "extension.puppetResource",
168177
"when": "resourceLangId == 'puppet'"
@@ -182,15 +191,20 @@
182191
"command": "extension.pdkNewClass",
183192
"group": "pdk@2"
184193
},
194+
{
195+
"when": "resourceLangId == 'puppet'",
196+
"command": "extension.pdkNewTask",
197+
"group": "pdk@3"
198+
},
185199
{
186200
"when": "resourceLangId == 'puppet' ",
187201
"command": "extension.pdkValidate",
188-
"group": "pdk@3"
202+
"group": "pdk@4"
189203
},
190204
{
191205
"when": "resourceLangId == 'puppet'",
192206
"command": "extension.pdkTestUnit",
193-
"group": "pdk@4"
207+
"group": "pdk@5"
194208
},
195209
{
196210
"when": "resourceLangId == 'puppet'",
@@ -211,14 +225,19 @@
211225
},
212226
{
213227
"when": "resourceLangId == 'puppet'",
214-
"command": "extension.pdkValidate",
228+
"command": "extension.pdkNewClass",
215229
"group": "pdk@2"
216230
},
217231
{
218232
"when": "resourceLangId == 'puppet'",
219-
"command": "extension.pdkTestUnit",
233+
"command": "extension.pdkValidate",
220234
"group": "pdk@3"
221235
},
236+
{
237+
"when": "resourceLangId == 'puppet'",
238+
"command": "extension.pdkTestUnit",
239+
"group": "pdk@4"
240+
},
222241
{
223242
"when": "resourceLangId == 'puppet'",
224243
"command": "extension.puppetShowNodeGraphToSide",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
import * as vscode from 'vscode';
4+
import * as cp from 'child_process';
5+
import ChildProcess = cp.ChildProcess;
6+
import { Logger } from '../../logging';
7+
import { reporter } from '../../telemetry/telemetry';
8+
import * as messages from '../../messages';
9+
10+
export class pdkNewTaskCommand {
11+
private logger: Logger = undefined;
12+
private terminal: vscode.Terminal = undefined;
13+
14+
constructor(logger: Logger, terminal: vscode.Terminal) {
15+
this.logger = logger;
16+
this.terminal = terminal;
17+
}
18+
19+
public run() {
20+
let nameOpts: vscode.QuickPickOptions = {
21+
placeHolder: "Enter a name for the new Puppet Task",
22+
matchOnDescription: true,
23+
matchOnDetail: true
24+
};
25+
vscode.window.showInputBox(nameOpts).then(taskName => {
26+
this.terminal.sendText(`pdk new task ${taskName}`);
27+
this.terminal.show();
28+
if (reporter) {
29+
reporter.sendTelemetryEvent(messages.PDKCommandStrings.PdkNewTaskCommandId);
30+
}
31+
})
32+
}
33+
34+
public dispose(): any {
35+
this.terminal.dispose();
36+
this.terminal = undefined;
37+
}
38+
}

client/src/commands/pdkcommands.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IConnectionManager } from '../../src/connection';
44
import { Logger } from '../../src/logging';
55
import { pdkNewModuleCommand } from './pdk/pdkNewModuleCommand';
66
import { pdkNewClassCommand } from './pdk/pdkNewClassCommand';
7+
import { pdkNewTaskCommand } from './pdk/pdkNewTaskCommand';
78
import { pdkValidateCommand } from './pdk/pdkValidateCommand';
89
import { pdkTestUnitCommand } from './pdk/pdkTestCommand';
910

@@ -19,6 +20,12 @@ export function setupPDKCommands(langID: string, connManager: IConnectionManager
1920
ctx.subscriptions.push(vscode.commands.registerCommand(messages.PDKCommandStrings.PdkNewClassCommandId, () => {
2021
newClassCommand.run();
2122
}));
23+
24+
let newTaskCommand = new pdkNewTaskCommand(logger, terminal);
25+
ctx.subscriptions.push(newClassCommand);
26+
ctx.subscriptions.push(vscode.commands.registerCommand(messages.PDKCommandStrings.PdkNewTaskCommandId, () => {
27+
newTaskCommand.run();
28+
}));
2229

2330
let validateCommand = new pdkValidateCommand(logger, terminal);
2431
ctx.subscriptions.push(validateCommand);

client/src/messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class PuppetCommandStrings{
4848
export class PDKCommandStrings {
4949
static PdkNewModuleCommandId: string = 'extension.pdkNewModule';
5050
static PdkNewClassCommandId: string = 'extension.pdkNewClass';
51+
static PdkNewTaskCommandId: string = 'extension.pdkNewTask';
5152
static PdkValidateCommandId: string = 'extension.pdkValidate';
5253
static PdkTestUnitCommandId: string = 'extension.pdkTestUnit';
5354
}

0 commit comments

Comments
 (0)