From c63c9b87289a827a5f01002146792e35ec245c45 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 19 Dec 2017 13:29:48 -0500 Subject: [PATCH] warn user of typos --- lib/cmd.js | 10 ++++++++-- package.json | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/cmd.js b/lib/cmd.js index 446c2ee60..af5d88152 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -1,5 +1,6 @@ const program = require('commander'); const promptly = require('promptly'); +const propose = require('propose'); const Embark = require('../lib/index'); let embark = new Embark; @@ -169,8 +170,13 @@ class Cmd { otherCommands() { program - .action(function (env) { - console.log('unknown command "%s"'.red, env); + .action(function (cmd) { + 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"); process.exit(0); }); diff --git a/package.json b/package.json index d66f4cc0e..52dcf8cd3 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "orbit-db": "^0.17.3", "parse-json": "^4.0.0", "promptly": "^2.1.0", + "propose": "0.0.5", "serve-static": "^1.11.1", "shelljs": "^0.5.0", "solc": "0.4.17",