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 | module.exports = args => ({errs = [], argv: ARGV = []} = {}) => { const opts = [] let at = 0 let ARG = ARGV[at] while (ARG) { const options = args[ARG] let at2 = 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 arg = ARGV[i] || '--' while (arg !== '--') { if (types === null) types = [] types.push('string') values.push(arg) i++ arg = ARGV[i] || '--' } } else { values = ARGV.slice(at + 1, at + types.length + 1) } opts.push({...option, values}) at2 = at + (types === null ? 0 : types.length) + 1 } } else { const values = ARGV.slice(at, at + 1) if (values.length > 0) opts.push({values}) } at = at2 ARG = ARGV[at] } return {errs, opts} } |