(commandName: string, commands: Command[])
| 702 | } |
| 703 | |
| 704 | export function getCommand(commandName: string, commands: Command[]): Command { |
| 705 | const command = findCommand(commandName, commands) |
| 706 | if (!command) { |
| 707 | throw ReferenceError( |
| 708 | `Command ${commandName} not found. Available commands: ${commands |
| 709 | .map(_ => { |
| 710 | const name = getCommandName(_) |
| 711 | return _.aliases ? `${name} (aliases: ${_.aliases.join(', ')})` : name |
| 712 | }) |
| 713 | .sort((a, b) => a.localeCompare(b)) |
| 714 | .join(', ')}`, |
| 715 | ) |
| 716 | } |
| 717 | |
| 718 | return command |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * Formats a command's description with its source annotation for user-facing UI. |
no test coverage detected