If there is unused data in the command line, the thrown exception doesn't include the collected and left items
ThosRTanner opened this issue · 1 comments
https://github.com/jazzband/docopt-ng/blob/master/docopt/__init__.py#L920-L922
Because the message produced if you get to this point is extremely unhelpful, I wanted to inspect what had/hadn't been parsed and produce a more meaningful exception.
But because left
and collected
aren't passed, I've had to do a very nasty bit of code inspecting the stack to find out what they should have been.
Could they be passed in that particular instance so that the client has a chance of producing a more reasonable error (and it might be worth subclassing DocoptError so that it's clear to clients whether docopt has given up as opposed to finding a specific error).
You are suggesting changing this to DocoptExit(f"Warning: found unmatched (duplicate?) arguments {left}, parsed {collected}", left=left, collected=collected)
I think that would be very reasonable. I will review any PRs you send.