src/yake/cli_args.js
function ParseWithConfig(config, argv)
{
    const debug = false;
    const parser = dashdash.createParser({ options : config });
    const helpText = parser.help({ includeEnv : true }).trimRight();

    try
    {
        const opts = parser.parse(argv, 2);
        const innerOptions = parser.options;
        const keyValues = {};
        /**
         * From opts build a key/value object consting ONLY of the options keys and no extra stuff
         * Note that dashdash puts a bunch of other stuff in opts.
         * AND then wrap the keyValue object in a CliOptions object for returing
         */

        innerOptions.forEach((element) =>
        {
            const k = element.key;

            if (debug) debugLog(`loop k: ${k} v: ${opts[k]}`);
            const v = (opts.hasOwnProperty(k)) ? opts[k] : undefined;

            keyValues[k] = v;
        });
        /**
         * @NOTE - the next two variables are temporary and disappear when the function is complete
         * so there is no need to copy them
         */
        const cliOptions = CliOptions(keyValues);
        const cliArgs = CliArguments(opts._args);

        if (debug) debugLog(util.inspect(cliOptions.getOptions()));

        return [cliOptions, cliArgs, helpText];
    }
    catch (e)
    {
        debugger;
        console.log(e.stack);
        raiseError(`Command Line Parser found an error: ${e.message}`);
        console.error('Command Line Parser found an error: %s', e.message);
        process.exit(1);
    }
}
function ParseWithConfig(config, argv)
{
    const debug = false;
    const parser = dashdash.createParser({ options : config });
    const helpText = parser.help({ includeEnv : true }).trimRight();

    try
    {
        const opts = parser.parse(argv, 2);
        const innerOptions = parser.options;
        const keyValues = {};
        /**
         * From opts build a key/value object consting ONLY of the options keys and no extra stuff
         * Note that dashdash puts a bunch of other stuff in opts.
         * AND then wrap the keyValue object in a CliOptions object for returing
         */

        innerOptions.forEach((element) =>
        {
            const k = element.key;

            if (debug) debugLog(`loop k: ${k} v: ${opts[k]}`);
            const v = (opts.hasOwnProperty(k)) ? opts[k] : undefined;

            keyValues[k] = v;
        });
        /**
         * @NOTE - the next two variables are temporary and disappear when the function is complete
         * so there is no need to copy them
         */
        const cliOptions = CliOptions(keyValues);
        const cliArgs = CliArguments(opts._args);

        if (debug) debugLog(util.inspect(cliOptions.getOptions()));

        return [cliOptions, cliArgs, helpText];
    }
    catch (e)
    {
        debugger;
        console.log(e.stack);
        raiseError(`Command Line Parser found an error: ${e.message}`);
        console.error('Command Line Parser found an error: %s', e.message);
        process.exit(1);
    }
}
function ParseWithConfig ( config , argv ) { const debug = false ; const parser = dashdash . createParser ( { options : config } ) ; const helpText = parser . help ( { includeEnv : true } ) . trimRight ( ) ; try { const opts = parser . parse ( argv , 2 ) ; const innerOptions = parser . options ; const keyValues = { } ; /**
         * From opts build a key/value object consting ONLY of the options keys and no extra stuff
         * Note that dashdash puts a bunch of other stuff in opts.
         * AND then wrap the keyValue object in a CliOptions object for returing
         */ innerOptions . forEach ( ( element ) => { const k = element . key ; if ( debug ) debugLog ( ` ${ k } ${ opts [ k ] } ` ) ; const v = ( opts . hasOwnProperty ( k ) ) ? opts [ k ] : undefined ; keyValues [ k ] = v ; } ) ; /**
         * @NOTE - the next two variables are temporary and disappear when the function is complete
         * so there is no need to copy them
         */ const cliOptions = CliOptions ( keyValues ) ; const cliArgs = CliArguments ( opts . _args ) ; if ( debug ) debugLog ( util . inspect ( cliOptions . getOptions ( ) ) ) ; return [ cliOptions , cliArgs , helpText ] ; } catch ( e ) { debugger ; console . log ( e . stack ) ; raiseError ( ` ${ e . message } ` ) ; console . error ( 'Command Line Parser found an error: %s' , e . message ) ; process . exit ( 1 ) ; } }
ParseWithConfig - A function that parses an array of command line options and arguments

@param      {object}   config  The configuration
@param      {array}    argv    an array of things like command line options and arguments
@return     {array}     of CliOptions, CliAruments}   returns 2 values via an array.length = 2
ParseWithConfig - A function that parses an array of command line options and arguments