Skip to content
Myr

Use real didYouMean example for .on('command:*') (#1176)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent 1e1ed08 · Browse files · 1 file+6 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−4 removed

  • other:+6 added−4 removed

1 file+6 added−4 removed

modified:Readme.md+6 added-4 removed
552 unmodified lines
553program.on('option:verbose', function () {554 process.env.VERBOSE = this.verbose;555});556557// custom error on unknown command557program.on('command:*', function (operands) {559 console.error(`Invalid command '${operands[0]}'. Did you mean:`);560 console.error(mySuggestions(operands[0]));561 process.exit(1);558 console.error(`error: unknown command '${operands[0]}'`);559 const availableCommands = program.commands.map(cmd => cmd.name());560 const suggestion = didYouMean(operands[0], availableCommands);561 if (suggestion)562 console.error(`Did you mean '${suggestion}'?`);563 process.exitCode = 1;564});565```566567## Bits and pieces
158 unmodified lines