-
Notifications
You must be signed in to change notification settings - Fork 280
API | vorpal.catch
Matheus Fernandes edited this page May 8, 2016
·
2 revisions
Catch is a special type of Command
object, and is returned after vorpal.catch
is used.
Catch
is an extension of the Command
object, and is returned after vorpal.catch
is used. A catch
instance inherits all vorpal.command
methods, with the exception that it is only called when no other commands have been matched, instead of the automated help.
The .catch
method is identical to vorpal.command
, with the exception that only parameters are passed in. When the user types an invalid command, the .catch
method's .action
method is fired.
There can only be one .catch
method defined in an application.
vorpal
.catch('[words...]', 'Catches incorrect commands')
.action(function (args, cb) {
this.log(args.words.join(' ') + ' is not a valid command.');
cb();
});
This is excellent for applications that are expected to accept any type of command, such as a CLI app for doing google
searches.