-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.ts
51 lines (42 loc) · 1.43 KB
/
commands.ts
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
import * as vscode from 'vscode';
import { CustomTaskTerminal } from './custom-task-terminal';
export class Commands {
public async activate(context: vscode.ExtensionContext): Promise<void> {
context.subscriptions.push(
vscode.commands.registerCommand('web-extension-tasks.runTask', async () => this.runTask()),
vscode.commands.registerCommand('web-extension-tasks.showText', async () => this.showText())
);
}
protected async runTask(): Promise<void> {
const text = await vscode.window.showInputBox({
value: 'hello'
});
if (!text) {
return;
}
const definition = {
label: 'text-task',
type: 'web-extension-tasks.text-task',
text,
};
const task = new vscode.Task(
definition,
vscode.TaskScope.Workspace,
definition.label,
definition.type,
new vscode.CustomExecution(async resolved => new CustomTaskTerminal(resolved.text, true))
);
vscode.tasks.executeTask(task);
}
protected async showText(): Promise<void> {
const text = await vscode.window.showInputBox({
value: 'howdy'
});
if (!text) {
return;
}
const pty = new CustomTaskTerminal(text);
const term = vscode.window.createTerminal({ name: 'Text', pty });
term.show();
}
}