]> Git Repo - pico-vscode.git/blob - src/commands/command.mts
Fix linting errors
[pico-vscode.git] / src / commands / command.mts
1 import { commands, type Disposable } from "vscode";
2
3 export const extensionName = "raspberry-pi-pico";
4
5 export abstract class Command {
6   private readonly commandId: string;
7
8   protected constructor(commandId: string) {
9     this.commandId = commandId;
10   }
11
12   register(): Disposable {
13     return commands.registerCommand(
14       extensionName + "." + this.commandId,
15       this.execute.bind(this)
16     );
17   }
18
19   abstract execute(): Promise<void> | void;
20 }
21
22 export abstract class CommandWithResult<T> {
23   private readonly commandId: string;
24
25   protected constructor(commandId: string) {
26     this.commandId = commandId;
27   }
28
29   register(): Disposable {
30     return commands.registerCommand(
31       extensionName + "." + this.commandId,
32       this.execute.bind(this)
33     );
34   }
35
36   abstract execute(): Promise<T> | T;
37 }
38
39 export abstract class CommandWithArgs {
40   private readonly commandId: string;
41
42   protected constructor(commandId: string) {
43     this.commandId = commandId;
44   }
45
46   register(): Disposable {
47     return commands.registerCommand(
48       extensionName + "." + this.commandId,
49       this.execute.bind(this)
50     );
51   }
52
53   abstract execute(...args: unknown[]): Promise<void> | void;
54 }
This page took 0.035425 seconds and 4 git commands to generate.