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