lib/cli/runCmd.js
function _parseShellConfigOptions(argv) {
    var out = {};

    //`parse-pos-args` value is `true` by default, it must be
    //explicitly set to falsy value thus undefined & null values does not count
    if (argv['parse-pos-args'] === false || argv['parse-pos-args'] === 0) {
        setConfigPathOption(out);
        return out;
    }

    var options = argv.options.reduce(function(out, option, index) {
        if (index % 2 === 0) {
            out.names.push(option);
        } else {
            out.values.push(option);
        }
        return out;
    }, {
        names: [],
        values: []
    });

    if (argv.options.length % 2 !== 0) {
        throw new Error(
            `Invalid number of shell positional arguments received.
            Possitional arguments are expected to be in "[key] [value]" pairs`
        );
    }

    options.names.forEach(function(propPath, index) {
        _.set(
            out,
            propPath,
            json5.parse(options.values[index])
        );
    });

    setConfigPathOption(out);

    return out;

    function setConfigPathOption(obj) {
        //for overwriting expected config filepath we can use --config option only
        if (argv.config) {
            obj.fileConfigPath = argv.config;
            obj.fileConfigPath = path.normalize(obj.fileConfigPath);
        } else {
            delete obj.fileConfigPath;
        }
    }
}
function _parseShellConfigOptions(argv) {
    var out = {};

    //`parse-pos-args` value is `true` by default, it must be
    //explicitly set to falsy value thus undefined & null values does not count
    if (argv['parse-pos-args'] === false || argv['parse-pos-args'] === 0) {
        setConfigPathOption(out);
        return out;
    }

    var options = argv.options.reduce(function(out, option, index) {
        if (index % 2 === 0) {
            out.names.push(option);
        } else {
            out.values.push(option);
        }
        return out;
    }, {
        names: [],
        values: []
    });

    if (argv.options.length % 2 !== 0) {
        throw new Error(
            `Invalid number of shell positional arguments received.
            Possitional arguments are expected to be in "[key] [value]" pairs`
        );
    }

    options.names.forEach(function(propPath, index) {
        _.set(
            out,
            propPath,
            json5.parse(options.values[index])
        );
    });

    setConfigPathOption(out);

    return out;

    function setConfigPathOption(obj) {
        //for overwriting expected config filepath we can use --config option only
        if (argv.config) {
            obj.fileConfigPath = argv.config;
            obj.fileConfigPath = path.normalize(obj.fileConfigPath);
        } else {
            delete obj.fileConfigPath;
        }
    }
}
function _parseShellConfigOptions ( argv ) { var out = { } ; //`parse-pos-args` value is `true` by default, it must be //explicitly set to falsy value thus undefined & null values does not count if ( argv [ 'parse-pos-args' ] === false || argv [ 'parse-pos-args' ] === 0 ) { setConfigPathOption ( out ) ; return out ; } var options = argv . options . reduce ( function ( out , option , index ) { if ( index % 2 === 0 ) { out . names . push ( option ) ; } else { out . values . push ( option ) ; } return out ; } , { names : [ ] , values : [ ] } ) ; if ( argv . options . length % 2 !== 0 ) { throw new Error ( ` ` ) ; } options . names . forEach ( function ( propPath , index ) { _ . set ( out , propPath , json5 . parse ( options . values [ index ] ) ) ; } ) ; setConfigPathOption ( out ) ; return out ; function setConfigPathOption ( obj ) { //for overwriting expected config filepath we can use --config option only if ( argv . config ) { obj . fileConfigPath = argv . config ; obj . fileConfigPath = path . normalize ( obj . fileConfigPath ) ; } else { delete obj . fileConfigPath ; } } }
returns parsed object with positional shell arguments.
These options will then overwrite option values set in configuration file
@private
@param {Object} argv - shell arguments
@return {Object}
returns parsed object with positional shell arguments . These options will then overwrite option values set in configuration file