Skip to content
Myr

Merge pull request #234 from thethomaseffect/master

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

Changed some loc to make them more readable

authored by Thomas Geraghty · committed by Thomas Geraghty · parents 7064153, 71faa8a · Browse files · 1 file+13 added−8 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−8 removed

  • other:+13 added−8 removed

1 file+13 added−8 removed

modified:index.js+13 added-8 removed
11 unmodified lines
12/**13 * Expose the root command.14 */1516exports = module.exports = new Command;16exports = module.exports = new Command();1718/**19 * Expose `Command`.20 */
46 unmodified lines
67 * @api private68 */6970Option.prototype.is = function(arg){71 return arg == this.short72 || arg == this.long;71 return arg == this.short || arg == this.long;72};7374/**75 * Initialize a new `Command`.
231 unmodified lines
307 , oname = option.name()308 , name = camelcase(oname);309310 // default as 3rd arg312 if ('function' != typeof fn) defaultValue = fn, fn = null;311 if (typeof fn != 'function') {312 defaultValue = fn;313 fn = null;314 }315316 // preassign default value only for --no-*, [optional], or <required>317 if (false == option.bool || option.optional || option.required) {318 // when --no-* we make sure default is true
8 unmodified lines
327 // when it's passed assign the value328 // and conditionally invoke the callback329 this.on(oname, function(val){330 // coercion329 if (null !== val && fn) val = fn(val, undefined === self[name] ? defaultValue : self[name]);331 if (null !== val && fn) val = fn(val, undefined === self[name]332 ? defaultValue333 : self[name]);334335 // unassigned or bool336 if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) {337 // if no value, bool true, and we have a default, then use it!
104 unmodified lines
442 , index;443444 for (var i = 0, len = args.length; i < len; ++i) {445 arg = args[i];442 i > 0 && (lastOpt = this.optionFor(args[i-1]));446 if (i > 0) {447 lastOpt = this.optionFor(args[i-1]);448 }449450 if (lastOpt && lastOpt.required) {451 ret.push(arg);452 } else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) {
293 unmodified lines
746747 // Prepend the help information748 return [pad('-h, --help', width) + ' ' + 'output usage information']749 .concat(this.options.map(function(option){744 return pad(option.flags, width)745 + ' ' + option.description;750 return pad(option.flags, width) + ' ' + option.description;751 }))752 .join('\n');753};754
127 unmodified lines