Skip to content

Commit

Permalink
chore: make use of inhouse command recommendation (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored and Berkmann18 committed Nov 27, 2019
1 parent ed9d84d commit 7d83c7c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 1 addition & 14 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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 => {
Expand Down Expand Up @@ -183,7 +171,6 @@ promptForCommand(yargv)
case 'check':
return checkContributors(yargv)
default:
suggestCommands(command)
throw new Error(`Unknown command ${command}`)
}
})
Expand Down

0 comments on commit 7d83c7c

Please sign in to comment.