| 28 | |
| 29 | negativeNumbers.forEach(([value, consume]) => { |
| 30 | function callProgram(program, args, consume) { |
| 31 | if (consume) { |
| 32 | assert.doesNotThrow(() => { |
| 33 | program.parse(args, { from: 'user' }); |
| 34 | }); |
| 35 | } else { |
| 36 | assert.throws( |
| 37 | () => { |
| 38 | program.parse(args, { from: 'user' }); |
| 39 | }, |
| 40 | { code: 'commander.unknownOption' }, |
| 41 | ); |
| 42 | } |
| 43 | } |
| 44 | test(`when option-argument for short optional is ${value} then consumed=${consume}`, () => { |
| 45 | const program = createTestCommand(); |
| 46 | program.option('-o, --optional [value]', 'optional option'); |