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