mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-16 04:20:44 +00:00
20 lines
546 B
TypeScript
20 lines
546 B
TypeScript
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);
|
|
}
|