Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | module.exports = parser => ({errs = [], opts: OPTS = []} = {}) => { const args = {_: []} for (let i = 0; i < OPTS.length; i++) { const {key, values: argv, types, opts} = OPTS[i] if (typeof types === 'undefined') { if (key !== '--') args['_'] = args['_'].concat(argv) } else if (types === null) { const parse = parser(opts || []) const res = parse({errs: [], argv}) errs = errs.concat(res.errs) args[key] = Object.assign({}, args[key], res.args) } else if (types.length === 0) { args[key] = typeof args[key] === 'undefined' ? true : args[key] < 2 ? 2 : args[key] + 1 } else { args[key] = types.length === 1 ? argv[0] : argv } } return {errs, args} } |