Skip to content

Commit

Permalink
added interfaces to the command classes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucsomers101 committed Feb 27, 2024
1 parent fee447b commit 07b6dc8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
9 changes: 5 additions & 4 deletions src/commands/checkVersionCommand.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as vscode from 'vscode';
import { ampersandVersionChecker } from '../ampersand';

export class checkVersionCommand{
static checkVersionCommand()
{
export class checkVersionCommand implements ICommand{
commandName: string = "extension.checkVersion";

RunCommand(): void {
if (!vscode.workspace.rootPath) {
vscode.window.showWarningMessage("Checking ampersand only works if you work in a workspace.")
return null;
return;
}

let versionString : string = ampersandVersionChecker.getVersion();
Expand Down
8 changes: 4 additions & 4 deletions src/commands/generateAtlasCommand.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as vscode from 'vscode';
import { config, fileUtils, terminalUtils } from "../utils";
import { terminalBuilder } from '../builders';

export class generateAtlasCommand {
export class generateAtlasCommand implements ICommand {
commandName: string = "extension.generateAtlas";

private builder : terminalBuilder = new terminalBuilder();

public GenerateAtlasCommand()
{
RunCommand(): void {
if(config.mainScriptSetting === undefined || config.folderSetting === undefined)
return;

Expand Down
10 changes: 5 additions & 5 deletions src/commands/generateFunctionalSpecCommand.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as vscode from 'vscode';
import { config, fileUtils, terminalUtils } from '../utils';
import { terminalBuilder } from '../builders';

export class generateFunctionalSpecCommand{
private builder : terminalBuilder = new terminalBuilder();
export class generateFunctionalSpecCommand implements ICommand {
commandName: string = "extension.generateFunctionalSpec";

public GenerateFunctionalSpecCommand()
{
private builder : terminalBuilder = new terminalBuilder();

RunCommand(): void {
if(config.mainScriptSetting === undefined || config.folderSetting === undefined)
return;

Expand Down
6 changes: 4 additions & 2 deletions src/commands/generatePrototypeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import * as vscode from 'vscode';
import { terminalBuilder } from "../builders/terminalBuilder";
import { manifest } from '../models/manifest';

export class generatePrototypeCommand {
export class generatePrototypeCommand implements ICommand {
commandName: string = "extension.generatePrototype";

static portForwardTerminal: vscode.Terminal | undefined = undefined;
private builder : terminalBuilder = new terminalBuilder();

Expand All @@ -14,7 +16,7 @@ export class generatePrototypeCommand {
this.manifestFile = new manifest(context.extensionPath);
}

public async GeneratePrototypeCommand()
public async RunCommand()
{
this.tryKillPortForwardedProcessAndTerminal();

Expand Down
20 changes: 12 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import * as fs from 'fs';
import { fileUtils, watcherUtils } from "./utils";
import { ampersandVersionChecker } from './ampersand';
import { constants } from './constants';
import { generateFunctionalSpecCommand, checkVersionCommand, generateAtlasCommand, generatePrototypeCommand } from './commands';
import { checkVersionCommand, generateAtlasCommand, generateFunctionalSpecCommand, generatePrototypeCommand } from './commands';

let generatePrototypeCommandInstance: generatePrototypeCommand;
let generateFunctionalSpecCommandInstance : generateFunctionalSpecCommand;
let generateAtlasCommandInstance : generateAtlasCommand;
let commands: ICommand[];

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
Expand All @@ -24,10 +22,16 @@ export function activate(context: vscode.ExtensionContext) {

watcherUtils.setupLastRunningWatcher(context);

pushDisposable(context, "extension.checkVersion", () => checkVersionCommand.checkVersionCommand())
pushDisposable(context, "extension.generateFunctionalSpec", () => new generateFunctionalSpecCommand().GenerateFunctionalSpecCommand())
pushDisposable(context, "extension.generateAtlas", () => new generateAtlasCommand().GenerateAtlasCommand())
pushDisposable(context, "extension.generatePrototype", () => new generatePrototypeCommand(context).GeneratePrototypeCommand())
commands.push(
new generatePrototypeCommand(context),
new generateAtlasCommand(),
new generateFunctionalSpecCommand(),
new checkVersionCommand()
);

commands.forEach(command => {
pushDisposable(context, command.commandName, () => command.RunCommand());
});

generateWorkingFolders();
createAndFillGitIgnore();
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/ICommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface ICommand {
readonly commandName : string;
RunCommand(): void;
}

0 comments on commit 07b6dc8

Please sign in to comment.