Skip to content
Myr

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

1 file+13 added−15 removed

modified:index.js+13 added-15 removed
182 unmodified lines
183 */184185Command.prototype.arguments = function (desc) {186 return this.parseExpectedArgs(desc.split(/ +/));187}187};188189/**190 * Add an implicit `help [cmd]` subcommand191 * which invokes `--help` for the given command.
252 unmodified lines
444445 // guess name446 this._name = this._name || basename(argv[1], '.js');447448 // 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 lines
543 }544 process.exit(1);545 });546547 // Store the reference to the child process548 this.runningCommand = proc;549};550551/**
279 unmodified lines
831 * @api public832 */833834Command.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 lines
910 var width = this.largestOptionLength();911912 // 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};919920/**921 * Return command help documentation.
13 unmodified lines
935 }).join(' ');936937 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 });945946 var width = commands.reduce(function(max, command) {947 return Math.max(max, command[0].length);948 }, 0);949950 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