Open
Description
Giving multiple identical arguments to something like [<item>...]
returns only one instance of the argument. python docopt does the right thing. Example:
usage = """
Usage:
echo [<item>...]
"""
{docopt} = require '../docopt'
console.log docopt(usage, version: '2.0')
Now, coffee bug.coffee a a a
returns
{ '<item>': [ 'a' ] }
whereas it really ought to return
{ '<item>': [ 'a', 'a', 'a' ] }
The problem is with this line in the Argument class:
left = (l for l in left when l.toString() isnt args[0].toString())
which will take out every instance matching args[0] when it really ought to remove only the first one, like in the python implementation.
I changed it as follows to make it work
- left = (l for l in left when l.toString() isnt args[0].toString())
+ idx = left.indexOf args[0]
+ left = left.slice(0, idx).concat(left.slice(idx + 1))
but I don't know coffeescript so maybe there's a better way of doing it.
Metadata
Metadata
Assignees
Labels
No labels