Peter Carter
Peter Carter

Reputation: 2728

How do I make Vorpal output a description of a command

Currently my code looks like this:

var vorpal = require('vorpal')();

console.log("Are you sure you wish to investigate the murder?")

vorpal
.delimiter('grey9nr$')
.show();

vorpal.command('Yes')
.action(function(args, cb){
const self = this;
this.prompt({
type: 'confirm',
name: 'continue',
default: false,
message: 'That sounds like a really bad idea. Continue?',
}, function(result){
if (result.continue) {
self.log('Good move.');
cb();
} else {
self.log('Your life is in danger. We will contact you with more information in due course.');
app.destroyDatabase(cb);
}
});
});

Which results in the following:

Screenshot

I would like to be able to define what yes means so the player knows what answering 'yes' will do, or require them to do.

Upvotes: 0

Views: 243

Answers (1)

Aljoscha Meyer
Aljoscha Meyer

Reputation: 679

You can either pass the description as the second parameter of the command() function, or explicitly set it with description().

Either

vorpal.command('Yes', `These words will show up in the help')
.action(function(args, cb){
...

or

vorpal.command('Yes')
.description('`These words will show up in the help'')
.action(function(args, cb){
...

Upvotes: 3

Related Questions