Sha256: 8721cd4a10cdb7b1233273a3a663f63dc0b87e8f98fac80bc9efac0ac4904a00

Contents?: true

Size: 1.21 KB

Versions: 69

Compression:

Stored size: 1.21 KB

Contents

var mout = require('mout');
var nopt = require('nopt');
var renderers = require('../renderers');

function readOptions(options, argv) {
    var types;
    var noptOptions;
    var parsedOptions = {};
    var shorthands = {};

    if (Array.isArray(options)) {
        argv = options;
        options = {};
    } else {
        options = options || {};
    }

    types = mout.object.map(options, function (option) {
        return option.type;
    });
    mout.object.forOwn(options, function (option, name) {
        shorthands[option.shorthand] = '--' + name;
    });

    noptOptions = nopt(types, shorthands, argv);

    // Filter only the specified options because nopt parses every --
    // Also make them camel case
    mout.object.forOwn(noptOptions, function (value, key) {
        if (options[key]) {
            parsedOptions[mout.string.camelCase(key)] = value;
        }
    });

    parsedOptions.argv = noptOptions.argv;

    return parsedOptions;
}

function getRenderer(command, json, config) {
    if (config.json || json) {
        return new renderers.Json(command, config);
    }

    return new renderers.Standard(command, config);
}

module.exports.readOptions = readOptions;
module.exports.getRenderer = getRenderer;

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.6.2 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.6.1 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.6 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.19 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.18 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.17 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.16 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.15 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.14 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.13 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.12 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.11 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.10 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.9 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.8 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.7 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.6 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.5 node_modules/bower/lib/util/cli.js
trusty-festivity-extension-2.5.4 node_modules/bower/lib/util/cli.js