MCPcopy
hub / github.com/tj/commander.js / callProgram

Function callProgram

tests/negatives.test.js:30–43  ·  view source on GitHub ↗
(program, args, consume)

Source from the content-addressed store, hash-verified

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');

Callers 1

negatives.test.jsFile · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected