-------------------------- PROGRAM HELPERS --------------------------
function updateConfig(config) {
    config = config || {};
    if (argv.src && argv.src.length) {
        config.src = [];
        let s, p;
        const named = {};
        _.each(argv.src, item => {
            s = item.split(':');
            if (s.length > 1) {
                p = s[0];
                named[p] = named[p] || [];
                named[p].push(s.slice(1));
            } else {
                config.src.push(item);
            }
        });
        if (_.keys(named).length) config.src.push(named);
    }

    if (argv.dest) config.dest = argv.dest;
    if (argv.clean) config.clean = Boolean(argv.clean);

    if (argv.base) {
        config.app = config.app || {};
        config.app.base = argv.base;
    }

    // DEBUG OPTIONS

    let debug = 0;

    if (argv.debug) {
        debug |= 31;
    } else {
        if (argv['web-logs']) debug |= 2;
        if (argv.verbose) debug |= 4;
        if (argv.nomin) debug |= 8;
        if (argv['jd-out']) debug |= 16;
    }

    if (debug > 0) {
        config.debug = debug;
    } else {
        config.debug = typeof config.debug === 'boolean'
            ? (config.debug ? 31 : 1)
            : (typeof config.debug === 'number' ? config.debug : 1);
    }

    if (argv.quiet) {
        config.debug &= ~1; // unset node logs
    } else {
        if (config.debug & 1 === 0) config.debug = 1;
    }

    return config;
}