Skip to content

Commit

Permalink
fix: error if a command is registered twice (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahsnider authored Sep 6, 2024
1 parent df01de5 commit d2f54a4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sources/advanced/Cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ export class Cli<Context extends BaseContext = BaseContext> implements Omit<Mini
* Registers a command inside the CLI.
*/
register(commandClass: CommandClass<Context>) {
if (this.registrations.has(commandClass)) {
throw new RangeError(`${commandClass.name} has already been registered`);
}

const specs = new Map<string, CommandOption<any>>();

const command = new commandClass();
Expand Down

0 comments on commit d2f54a4

Please sign in to comment.