[refactor] commands
This commit is contained in:
5
client/src/command/Command.ts
Normal file
5
client/src/command/Command.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
export interface Command{
|
||||
getCommandName():string;
|
||||
getCommandHandler():(...args:any)=>Promise<any>;
|
||||
}
|
26
client/src/command/CompileCommand.ts
Normal file
26
client/src/command/CompileCommand.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { window } from 'vscode';
|
||||
import { Command as BranFlakesCommand } from './Command';
|
||||
import { VSCodePromptInputStrategy } from '../input/VSCodePromptInputStrategy';
|
||||
import BranFlakesExecutorVisitor from '../BranFlakesExecutorVisitor';
|
||||
|
||||
export class CompileBranFlakesCommand implements BranFlakesCommand {
|
||||
getCommandName() {
|
||||
return 'bf.execute';
|
||||
}
|
||||
getCommandHandler() {
|
||||
return async () => {
|
||||
const text = window.activeTextEditor.document.getText();
|
||||
const fn = window.activeTextEditor.document.fileName;
|
||||
const inputStrategy = new VSCodePromptInputStrategy(
|
||||
window.showInputBox
|
||||
);
|
||||
const output = await BranFlakesExecutorVisitor.run(
|
||||
text,
|
||||
fn,
|
||||
inputStrategy,
|
||||
window.showInformationMessage
|
||||
);
|
||||
await window.showInformationMessage(`Output: ${output}`);
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user