2015-10-17 32 views
0

目前我的代碼看起來是這樣的:如何使Vorpal輸出命令的說明

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); 
} 
}); 
}); 

導致以下:

Screenshot

我想能夠定義什麼是意味着讓玩家知道回答「是」會做什麼,或者要求他們去做。

回答

3

您可以將描述作爲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){ 
... 
+0

感謝花花公子。我會很快將它添加到網站中。 –