1 | "use strict";
|
2 |
|
3 | const meant = require(`meant`);
|
4 |
|
5 | function didYouMean(scmd, commands) {
|
6 | const bestSimilarity = meant(scmd, commands).map(function (str) {
|
7 | return ` ${str}`;
|
8 | });
|
9 | if (bestSimilarity.length === 0) return ``;
|
10 |
|
11 | if (bestSimilarity.length === 1) {
|
12 | return `\nDid you mean this?\n ${bestSimilarity[0]}\n`;
|
13 | } else {
|
14 | return [`\nDid you mean one of these?`].concat(bestSimilarity.slice(0, 3)).join(`\n`) + `\n`;
|
15 | }
|
16 | }
|
17 |
|
18 | module.exports = didYouMean; |
\ | No newline at end of file |