From 7d83c7cac195b97ad3cc2e971e536fa7e9792d77 Mon Sep 17 00:00:00 2001 From: James George Date: Thu, 28 Nov 2019 01:19:17 +0530 Subject: [PATCH] chore: make use of inhouse command recommendation (#228) --- package.json | 1 - src/cli.js | 15 +-------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/package.json b/package.json index ebd44db..182b64b 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "@babel/runtime": "^7.2.0", "async": "^3.0.1", "chalk": "^3.0.0", - "didyoumean": "^1.2.1", "inquirer": "^6.2.1", "json-fixer": "^1.3.1-0", "lodash": "^4.11.2", diff --git a/src/cli.js b/src/cli.js index e3d728c..b07cfb7 100755 --- a/src/cli.js +++ b/src/cli.js @@ -5,10 +5,6 @@ const path = require('path') const yargs = require('yargs') const chalk = require('chalk') const inquirer = require('inquirer') -const didYouMean = require('didyoumean') - -// Setting edit length to be 60% of the input string's length -didYouMean.threshold = 0.6 const init = require('./init') const generate = require('./generate') @@ -24,6 +20,7 @@ const yargv = yargs .alias('h', 'help') .alias('v', 'version') .version() + .recommendCommands() .command('generate', 'Generate the list of contributors') .usage('Usage: $0 generate') .command('add', 'add a new contributor') @@ -50,15 +47,6 @@ const yargv = yargs } }).argv -function suggestCommands(cmd) { - const availableCommands = ['generate', 'add', 'init', 'check'] - const suggestion = didYouMean(cmd, availableCommands) - - if (suggestion) { - console.log(chalk.bold(`Did you mean ${suggestion}`)) - } -} - function startGeneration(argv) { return Promise.all( argv.files.map(file => { @@ -183,7 +171,6 @@ promptForCommand(yargv) case 'check': return checkContributors(yargv) default: - suggestCommands(command) throw new Error(`Unknown command ${command}`) } })