optparse-js
optparse-js copied to clipboard
Reset arg if it was a switch and not an argument
The following:
var parser = new OptionParser([['-e', '--example [STRING]']]);
parser.parse(['--example', '--help']);
passes "--help" as arg to the example handler even though the --help switch will be handled later on. This patch fixes this and passes undefined to the example handler function.
Note: merging this will most likely conflict with pull request #14. Ultimately it should not make much difference whether you put the arg = undefined; inside or below the if block.
I’ve rebased this pull request atop the current master so it should be fine to merge automatically.