Skip to content
This repository has been archived by the owner on Dec 23, 2018. It is now read-only.

Commit

Permalink
Merge pull request #47 from mbachvarov/new
Browse files Browse the repository at this point in the history
Error handling when unknown command is called
  • Loading branch information
Craig Jefferds committed Oct 9, 2014
2 parents 8955f8e + dbfca8a commit 479e85d
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions lib/plugins/enter.js
Expand Up @@ -30,25 +30,19 @@ exports.plugin = function(commandRoute, cli) {

}

cli.onCommand('enter', function() {

var failed = false;

var commands = cli.buffer().replace(cli.inputPrefix(),'').split(';'),
running = commands.length;

commands.forEach(function(command) {
process.nextTick(function() {
cli.emit(command, null, function(success) {
failed = !success || failed;

if(!(--running) && failed) {
process.nextTick(cli.help);
}
})
})
});

});

}
cli.onCommand('enter', function() {
var failed = false;
var commands = cli.buffer().replace(cli.inputPrefix(),'').split(';'),
running = commands.length;
commands.forEach(function(command) {
process.nextTick(function() {
var success= cli.emit(command, null);
failed = !success || failed;
if(!(--running) && failed) {
console.log("Wrong command!");
process.nextTick(cli.help);
}
});
});
});
}

0 comments on commit 479e85d

Please sign in to comment.