Select Git revision
CommanderCommand.ts
CommanderCommand.ts 791 B
import { Command, CommandOptions } from 'commander';
abstract class CommanderCommand {
protected abstract commandName: string;
protected aliasNames: Array<string> = [];
protected options: CommandOptions = {};
command: Command = new Command();
registerOnCommand(parent: Command) {
this.command = parent.command(this.commandName, this.options).aliases(this.aliasNames);
this.defineCommand();
this.defineSubCommands();
}
protected abstract defineCommand(): void;
protected defineSubCommands() {
/*
* No action
* Override this method only if you need to define subcommands
* */
}
protected abstract commandAction(...args: Array<unknown>): Promise<void>;
}
export default CommanderCommand;