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 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | module.exports = args => ({errs = [], argv = []} = {}) => { let errs2 = [] const argv2 = [] let at = 0 let arg = argv[at] while (arg) { const options = args[arg] let newAt = at + 1 if (options) { for (let j = 0; j < options.length; j++) { const option = options[j] let {types} = option let values = [] if (typeof types === 'undefined' || types === null) { let i = at + 1 let arg2 = argv[i] || '--' while (arg2 !== '--') { if (types === null) types = [] types.push('string') values.push(arg2) i++ arg2 = argv[i] || '--' } } else { values = argv.slice(at + 1, at + types.length + 1) } argv2.push({...option, values}) newAt = at + (types === null ? 0 : types.length) + 1 } } else { const values = argv.slice(at, at + 1) if (values.length > 0) argv2.push({values}) } at = newAt arg = argv[at] } return {errs: errs.concat(errs2), argv: argv2} } |