fix the undefined in help #414
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by zhiyelee · committed by zhiyelee · parent f68ab32 · Browse files · 1 file·+13 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+13 added−15 removed
- other:+13 added−15 removed
Provenance
- Commit
619c648- Tree
8b1c9c8- Author
zhiyelee <zhiyelee@gmail.com>- Committer
zhiyelee <zhiyelee@gmail.com>- Parent
f68ab32
1 file changed+13 added−15 removed
modified:index.js+13 added-15 removed
182 unmodified lines183 */184 185 Command.prototype.arguments = function (desc) {186 return this.parseExpectedArgs(desc.split(/ +/));187-}187+};188 189 /**190 * Add an implicit `help [cmd]` subcommand191 * which invokes `--help` for the given command.252 unmodified lines444 445 // guess name446 this._name = this._name || basename(argv[1], '.js');447 448- // github-style sub-commands with no sub-command448+ // git-style sub-commands with no sub-command449 if (this.executables && argv.length < 3) {450 // this user needs help451 argv.push('--help');452 }90 unmodified lines543 }544 process.exit(1);545 });546 547+ // Store the reference to the child process548 this.runningCommand = proc;549 };550 551 /**279 unmodified lines831 * @api public832 */833 834 Command.prototype.description = function(str) {834- if (0 == arguments.length) return this._description;835+ if (0 === arguments.length) return this._description;836 this._description = str;837 return this;838 };839 70 unmodified lines910 var width = this.largestOptionLength();911 912 // Prepend the help information913 return [pad('-h, --help', width) + ' ' + 'output usage information']913- .concat(this.options.map(function(option) {914- return pad(option.flags, width) + ' ' + option.description;914+ .concat(this.options.map(function(option) {915+ return pad(option.flags, width) + ' ' + option.description;916 }))916- .join('\n');917+ .join('\n');918 };919 920 /**921 * Return command help documentation.13 unmodified lines935 }).join(' ');936 937 return [938 cmd._name938- + (cmd._alias939- ? '|' + cmd._alias940- : '')941- + (cmd.options.length942- ? ' [options]'943- : '')939+ + (cmd._alias ? '|' + cmd._alias : '')940+ + (cmd.options.length ? ' [options]' : '')941 + ' ' + args945- , cmd.description()942+ , cmd.description()943 ];944 });945 946 var width = commands.reduce(function(max, command) {947 return Math.max(max, command[0].length);948 }, 0);949 950 return [954- ''951+ ''952 , ' Commands:'953 , ''954 , commands.map(function(cmd) {955+ var desc = cmd[1] ? ' ' + cmd[1] : '';958- return pad(cmd[0], width) + ' ' + cmd[1];956+ return pad(cmd[0], width) + desc;957 }).join('\n').replace(/^/gm, ' ')958 , ''959 ].join('\n');960 };141 unmodified lines