function parseCLIArgsCore(set, args) {    // eslint-disable-line complexity
    LOOP:
    for (let i = 0; i < args.length; ++i) {
        const arg = args[i]

        switch (arg) {
            case "--":
                set.rest = args.slice(1 + i)
                break LOOP

            case "--color":
            case "--no-color":
                // do nothing.
                break

            case "-c":
            case "--continue-on-error":
                set.continueOnError = true
                break

            case "-l":
            case "--print-label":
                set.printLabel = true
                break

            case "-n":
            case "--print-name":
                set.printName = true
                break

            case "-r":
            case "--race":
                set.race = true
                break

            case "--silent":
                set.silent = true
                break

            case "--max-parallel":
                set.maxParallel = parseInt(args[++i], 10)
                if (!Number.isFinite(set.maxParallel) || set.maxParallel <= 0) {
                    throw new Error(`Invalid Option: --max-parallel ${args[i]}`)
                }
                break

            case "-s":
            case "--sequential":
            case "--serial":
                if (set.singleMode && arg === "-s") {
                    set.silent = true
                    break
                }
                if (set.singleMode) {
                    throw new Error(`Invalid Option: ${arg}`)
                }
                addGroup(set.groups)
                break

            case "--aggregate-output":
                set.aggregateOutput = true
                break

            case "-p":
            case "--parallel":
                if (set.singleMode) {
                    throw new Error(`Invalid Option: ${arg}`)
                }
                addGroup(set.groups, { parallel: true })
                break

            case "--npm-path":
                set.npmPath = args[++i] || null
                break

            default: {
                let matched = null
                if ((matched = OVERWRITE_OPTION.exec(arg))) {
                    overwriteConfig(
                        set.packageConfig,
                        matched[1],
                        matched[2],
                        matched[3] || args[++i]
                    )
                }
                else if ((matched = CONFIG_OPTION.exec(arg))) {
                    set.config[matched[1]] = matched[2]
                }
                else if (CONCAT_OPTIONS.test(arg)) {
                    parseCLIArgsCore(
                        set,
                        arg.slice(1).split("").map(c => `-${c}`)
                    )
                }
                else if (arg[0] === "-") {
                    throw new Error(`Invalid Option: ${arg}`)
                }
                else {
                    set.lastGroup.patterns.push(arg)
                }

                break
            }
        }
    }

    if (!set.parallel && set.aggregateOutput) {
        throw new Error("Invalid Option: --aggregate-output (without parallel)")
    }
    if (!set.parallel && set.race) {
        const race = args.indexOf("--race") !== -1 ? "--race" : "-r"
        throw new Error(`Invalid Option: ${race} (without parallel)`)
    }
    if (!set.parallel && set.maxParallel !== 0) {
        throw new Error("Invalid Option: --max-parallel (without parallel)")
    }

    return set
}
Parses CLI arguments.

@param {ArgumentSet} set - The parsed CLI arguments.
@param {string[]} args - CLI arguments.
@returns {ArgumentSet} set itself.