如何使 Vorpal 输出命令的描述
How do I make Vorpal output a description of a command
目前我的代码如下所示:
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);
}
});
});
结果如下:
我希望能够定义“是”的含义,以便玩家知道回答 'yes' 会做什么,或者要求他们做什么。
您可以将描述作为 command()
函数的第二个参数传递,或者使用 description()
明确设置。
两者都
vorpal.command('Yes', `These words will show up in the help')
.action(function(args, cb){
...
或
vorpal.command('Yes')
.description('`These words will show up in the help'')
.action(function(args, cb){
...
目前我的代码如下所示:
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);
}
});
});
结果如下:
我希望能够定义“是”的含义,以便玩家知道回答 'yes' 会做什么,或者要求他们做什么。
您可以将描述作为 command()
函数的第二个参数传递,或者使用 description()
明确设置。
两者都
vorpal.command('Yes', `These words will show up in the help')
.action(function(args, cb){
...
或
vorpal.command('Yes')
.description('`These words will show up in the help'')
.action(function(args, cb){
...