docopt.coffee
docopt.coffee copied to clipboard
Unexpected repeated arguments when using repeated option.
Docopt seems to erroneously repeat arguments when parsing an option block when:
- it is a repeating option.
- it has multiple matching options in the same '[ ]' block.
Environment:
- NodeJS: 5.7.0
- Docopt: 0.6.2
Test Cases:
const doc = `
Usage:
foobar [-f X ... | --foo X ...]
Options:
-f X, --foo X bar
`
console.log(require('docopt').docopt(doc))
const doc = `
Usage:
foobar [-f X ...] [--foo X ...]
Options:
-f X, --foo X bar.
`
console.log(require('docopt').docopt(doc))
Tests:
:-1:
<test case 1> -f 1 -f 2 -f 3 -f 4 -f 5 -f 6
{ '--foo': [ '1', '2', '3', '4', '5', '6', '2', '3', '4', '5', '6' ] }
:+1:
<test case 2> -f 1 -f 2 -f 3 -f 4 -f 5 -f 6
{ '--foo': [ '1', '2', '3', '4', '5', '6' ] }