-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
54 lines (45 loc) · 1.34 KB
/
extension.js
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
52
53
54
const vscode = require("vscode");
// Import libs to run the command
const cp = require("child_process");
var terminal;
function activate(context) {
// Define custom command
let runAardvarkProgramCommand = vscode.commands.registerCommand(
"aardvark.runAardvarkProgram",
async () => {
// Get the active text editor
const editor = vscode.window.activeTextEditor;
if (!editor) {
vscode.window.showErrorMessage("No active text editor.");
return;
}
// Get the file path of the active document
const filePath = editor.document.fileName;
if (!terminal) {
// Create a new terminal
terminal = vscode.window.createTerminal("Aardvark Terminal");
}
// Run the Aardvark program in the terminal
terminal.sendText(`adk run "${filePath}"`);
// Show the terminal
terminal.show();
}
);
// Register custom command
context.subscriptions.push(runAardvarkProgramCommand);
// Define toolbar button
let runAardvarkProgramButton = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left
);
runAardvarkProgramButton.text = "$(triangle-right) Run Aardvark Program";
runAardvarkProgramButton.command = "aardvark.runAardvarkProgram";
// Register toolbar button
context.subscriptions.push(runAardvarkProgramButton);
}
function deactivate() {
serverProcess.kill();
}
module.exports = {
activate,
deactivate,
};