Skip to content

Instantly share code, notes, and snippets.

@rcla
Created June 25, 2021 14:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rcla/4715e27062c59a0d2ac70e6730b85ef6 to your computer and use it in GitHub Desktop.
import { injectable, inject } from "inversify";
import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService } from "@theia/core/lib/common";
import { CommonMenus } from "@theia/core/lib/browser";
import { TaskConfiguration, TaskScope } from '@theia/task/lib/common';
import { TaskService } from '@theia/task/lib/browser/task-service';
export const TestMakeCommand = {
id: 'TestMake.command',
label: "Test Make"
};
const myTask: TaskConfiguration = {
"_scope": TaskScope.Global,
"label": "Test Make",
"type": "shell",
"command": "/usr/bin/make",
"args": [
"-v"
],
"options": {
"cwd": "/home/bud-rey/Test"
}
}
@injectable()
export class TestMakeCommandContribution implements CommandContribution {
constructor(
@inject(TaskService) private readonly taskService: TaskService,
@inject(MessageService) private readonly messageService: MessageService,
) { }
registerCommands(registry: CommandRegistry): void {
registry.registerCommand(TestMakeCommand, {
execute: () => {
this.taskService.runTask(myTask);
this.messageService.info('Test Make');
}
});
}
}
@injectable()
export class TestMakeMenuContribution implements MenuContribution {
registerMenus(menus: MenuModelRegistry): void {
menus.registerMenuAction(CommonMenus.EDIT_FIND, {
commandId: TestMakeCommand.id,
label: TestMakeCommand.label
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment