Skip to content
Myr

Merge pull request #237 from rlidwka/236

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Make padding for options and commands consistent

authored by Thomas Geraghty · committed by Thomas Geraghty · parents 4428a07, 5d3ea91 · Browse files · 1 file+24 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−15 removed

  • other:+24 added−15 removed

1 file+24 added−15 removed

modified:index.js+24 added-15 removed
763 unmodified lines
764 */765766Command.prototype.commandHelp = function(){767 if (!this.commands.length) return '';768 return [769 ''770 , ' Commands:'771 , ''772 , this.commands.map(function(cmd){773 var args = cmd._args.map(function(arg){774 return arg.required775 ? '<' + arg.name + '>'776 : '[' + arg.name + ']';777 }).join(' ');768769 var commands = this.commands.map(function(cmd) {770 var args = cmd._args.map(function(arg){771 return arg.required772 ? '<' + arg.name + '>'773 : '[' + arg.name + ']';774 }).join(' ');775776 return [779 return cmd._name777 cmd._name778 + (cmd._alias779 ? '|' + cmd._alias780 : '')781 + (cmd.options.length782 ? ' [options]'785 : '') + ' ' + args786 + (cmd.description()787 ? '\n ' + cmd.description()783 : '')789 + '\n';784 + ' ' + args785 , cmd.description()786 ];787 });788789 var width = commands.reduce(function(max, command){790 return Math.max(max, command[0].length);791 }, 0);792793 return [794 ''795 , ' Commands:'796 , ''797 , commands.map(function(cmd){798 return pad(cmd[0], width) + ' ' + cmd[1];799 }).join('\n').replace(/^/gm, ' ')800 , ''801 ].join('\n');802};
92 unmodified lines