Skip to content

Commit

Permalink
avoid printing the command usage twice, and support an array of usage…
Browse files Browse the repository at this point in the history
… patterns.
  • Loading branch information
Adrian Rossouw committed Jun 27, 2011
1 parent 5baf872 commit b5feaa8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions server/plugin.js
Expand Up @@ -216,16 +216,21 @@ Plugin.prototype.help = function(callback) {
if (command !== false && command in this.commands) {
// Display information about this command.
var command = this.commands[command];
output.push(['Usage: %s', utils.colorize(this.argv['$0'] + ' ' +
command.title +
(command.usage ? ' ' + command.usage : '') +
' [options...]', 'green')]);

output.push(['%s%s: %s',
utils.colorize(command.title, 'yellow', 'bold'),
utils.colorize(command.usage ? ' ' + command.usage : '', 'yellow'),
command.description]);
output.push(['Usage: %s', utils.colorize(this.argv['$0'] + ' <command> [options...]', 'green')]);

output.push(["Commands: " + command.description]);

var usage = command.usage || [''];
_(_.isArray(usage) ? usage : [usage]).each(function(item) {
output.push([
' %s %s',
utils.colorize(command.title, 'yellow', 'bold'),
utils.colorize(item, 'yellow'),
]);
});

output.push(['\nOptions : ']);
var options = [];
for (var key in command.options) {
var option = command.options[key];
Expand Down

0 comments on commit b5feaa8

Please sign in to comment.