warn user of typos

This commit is contained in:
Iuri Matias 2017-12-19 13:29:48 -05:00
parent 1e9439bbe6
commit c63c9b8728
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,6 @@
const program = require('commander'); const program = require('commander');
const promptly = require('promptly'); const promptly = require('promptly');
const propose = require('propose');
const Embark = require('../lib/index'); const Embark = require('../lib/index');
let embark = new Embark; let embark = new Embark;
@ -169,8 +170,13 @@ class Cmd {
otherCommands() { otherCommands() {
program program
.action(function (env) { .action(function (cmd) {
console.log('unknown command "%s"'.red, env); console.log('unknown command "%s"'.red, cmd);
let dictionary = ['new', 'demo', 'build', 'run', 'blockchain', 'simulator', 'test', 'upload', 'version' ];
let suggestion = propose(cmd, dictionary, {threshold: 0.3});
if (suggestion) {
console.log('did you mean "%s"?'.green, suggestion);
}
console.log("type embark --help to see the available commands"); console.log("type embark --help to see the available commands");
process.exit(0); process.exit(0);
}); });

View File

@ -41,6 +41,7 @@
"orbit-db": "^0.17.3", "orbit-db": "^0.17.3",
"parse-json": "^4.0.0", "parse-json": "^4.0.0",
"promptly": "^2.1.0", "promptly": "^2.1.0",
"propose": "0.0.5",
"serve-static": "^1.11.1", "serve-static": "^1.11.1",
"shelljs": "^0.5.0", "shelljs": "^0.5.0",
"solc": "0.4.17", "solc": "0.4.17",