Skip to content
Myr

Merge pull request #262 from tonylukasavage/options_func

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

add opts() for getting key-value pairs of options

authored by Thomas Geraghty · committed by Thomas Geraghty · parents c0fcf8f, ed8c945 · Browse files · 2 files+38 added−0 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+38 added−0 removed

  • tests:+21 added−0 removed
  • other:+17 added−0 removed

2 files+38 added−0 removed

added:test/test.options.func.js+21 added
modified:index.js+17 added
600 unmodified lines
601 return { args: args, unknown: unknownOptions };602};603604/**605 * Return an object containing options as key-value pairs606 *607 * @return {Object}608 * @api public609 */610Command.prototype.opts = function() {611 var result = {}612 , len = this.options.length;613614 for (var i = 0 ; i < len; i++) {615 var key = this.options[i].name();616 result[key] = key === 'version' ? this._version : this[key];617 }618 return result;619};620621/**622 * Argument `name` is missing.623 *624 * @param {String} name625 * @api private
287 unmodified lines