Skip to content
Myr

Merge pull request #416 from zhiyelee/zhiyelee/fixHelpUndefined

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

fix the undefined in help #414

authored by Zhiye Li · committed by Zhiye Li · parents 86467e3, e553d4c · Browse files · 2 files+26 added−14 removed
This commit

State

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

Diff stats

2 files+26 added−14 removed

  • tests:+14 added−0 removed
  • other:+12 added−14 removed

2 files+26 added−14 removed

added:test/test.command.help.js+14 added
modified:index.js+12 added-14 removed
183 unmodified lines
184 */185186Command.prototype.arguments = function (desc) {187 return this.parseExpectedArgs(desc.split(/ +/));188}188};189190/**191 * Add an implicit `help [cmd]` subcommand192 * which invokes `--help` for the given command.
355 unmodified lines
548 }549 process.exit(1);550 });551552 // Store the reference to the child process553 this.runningCommand = proc;554};555556/**
279 unmodified lines
836 * @api public837 */838839Command.prototype.description = function(str) {839 if (0 == arguments.length) return this._description;840 if (0 === arguments.length) return this._description;841 this._description = str;842 return this;843};844
70 unmodified lines
915 var width = this.largestOptionLength();916917 // Prepend the help information918 return [pad('-h, --help', width) + ' ' + 'output usage information']918 .concat(this.options.map(function(option) {919 return pad(option.flags, width) + ' ' + option.description;919 .concat(this.options.map(function(option) {920 return pad(option.flags, width) + ' ' + option.description;921 }))921 .join('\n');922 .join('\n');923};924925/**926 * Return command help documentation.
13 unmodified lines
940 }).join(' ');941942 return [943 cmd._name943 + (cmd._alias944 ? '|' + cmd._alias945 : '')946 + (cmd.options.length947 ? ' [options]'948 : '')944 + (cmd._alias ? '|' + cmd._alias : '')945 + (cmd.options.length ? ' [options]' : '')946 + ' ' + args950 , cmd.description()947 , cmd.description()948 ];949 });950951 var width = commands.reduce(function(max, command) {952 return Math.max(max, command[0].length);953 }, 0);954955 return [959 ''956 ''957 , ' Commands:'958 , ''959 , commands.map(function(cmd) {960 var desc = cmd[1] ? ' ' + cmd[1] : '';963 return pad(cmd[0], width) + ' ' + cmd[1];961 return pad(cmd[0], width) + desc;962 }).join('\n').replace(/^/gm, ' ')963 , ''964 ].join('\n');965};
142 unmodified lines