refactor(cli): extract shared command-removal and timeout action helpers

This commit is contained in:
Peter Steinberger
2026-02-21 20:18:00 +00:00
parent bb490a4b51
commit 944913fc98
5 changed files with 81 additions and 40 deletions

View File

@@ -0,0 +1,19 @@
import type { Command } from "commander";
export function removeCommand(program: Command, command: Command): boolean {
const commands = program.commands as Command[];
const index = commands.indexOf(command);
if (index < 0) {
return false;
}
commands.splice(index, 1);
return true;
}
export function removeCommandByName(program: Command, name: string): boolean {
const existing = program.commands.find((command) => command.name() === name);
if (!existing) {
return false;
}
return removeCommand(program, existing);
}