* Unknown command. * * @private
()
| 2174 | */ |
| 2175 | |
| 2176 | unknownCommand() { |
| 2177 | const unknownName = this.args[0]; |
| 2178 | let suggestion = ''; |
| 2179 | |
| 2180 | if (this._showSuggestionAfterError) { |
| 2181 | const candidateNames = []; |
| 2182 | this.createHelp() |
| 2183 | .visibleCommands(this) |
| 2184 | .forEach((command) => { |
| 2185 | candidateNames.push(command.name()); |
| 2186 | // just visible alias |
| 2187 | if (command.alias()) candidateNames.push(command.alias()); |
| 2188 | }); |
| 2189 | suggestion = suggestSimilar(unknownName, candidateNames); |
| 2190 | } |
| 2191 | |
| 2192 | const message = `error: unknown command '${unknownName}'${suggestion}`; |
| 2193 | this.error(message, { code: 'commander.unknownCommand' }); |
| 2194 | } |
| 2195 | |
| 2196 | /** |
| 2197 | * Get or set the program version. |
no test coverage detected