.action --> doAction

This commit is contained in:
Siddharth Singh 2024-09-30 02:39:05 +05:30
parent f452e8324f
commit f87e76d624
No known key found for this signature in database

View file

@ -5,7 +5,7 @@ import { parseSubcommand } from './parsing.ts';
export class Command {
name: string;
description: string;
action: (args: ParsedArgs) => void | Promise<void> = (_) => {};
private action: (args: ParsedArgs) => void | Promise<void> = (_) => {};
options: Record<string, Option> = {};
commands: Record<string, Command> = {};
@ -38,6 +38,10 @@ export class Command {
return this;
}
async doAction(args: ParsedArgs) {
return await this.action(args);
}
subcommand(command: Command) {
if (this.isValidSubcommand(command.name)) {
throw new Error(`tribes-cli: ${command.name} is already a subcommand.`);