jfd/optparse-js — pull request #8 by mogsie (2013-02-03 20:18:53+00:00)
Title: 1 bugfix, 1 new feature

This pull request fixes issue #3. The fix is just an uninitialized variable.

The pull request also adds a new feature to the halt callback. My goal was to be able to make a command which had global options, then a command, then suboptions:

bin/mycommand --global=aaa sub1 --sub1-specific
bin/mycommand --global=bbb sub2 --sub2-specific

So I wanted to parse the command line up until (and including) the first word (`parser.on(2, ...)`. A halt() seems the correct thing to do, but the "remaining, unparsed arguments" are lost. So I decided to pass them in the halt event handler. That way, I can make a new parser with different options to parse the remainder of the arguments.