Skip to content

Commit

Permalink
Add outputHelp method to Command object.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik Viswanathan committed Aug 23, 2012
1 parent 2aac48f commit a42471a
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/commander.js
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,18 @@ Command.prototype.choose = function(list, index, fn){
again();
};


/**
* Output help information for this command
*
* @api public
*/

Command.prototype.outputHelp = function() {
process.stdout.write(this.helpInformation());
this.emit('--help');
}

/**
* Camel-case the given `flag`
*
Expand Down Expand Up @@ -1023,8 +1035,7 @@ function outputHelpIfNecessary(cmd, options) {
options = options || [];
for (var i = 0; i < options.length; i++) {
if (options[i] == '--help' || options[i] == '-h') {
process.stdout.write(cmd.helpInformation());
cmd.emit('--help');
cmd.outputHelp();
process.exit(0);
}
}
Expand Down

0 comments on commit a42471a

Please sign in to comment.