jfd/optparse-js — pull request #14 by sabberworm (2014-03-19 11:14:46+00:00)
Title: Fix missing argument validation on last option

Normally, omitting an argument to a switch yields in a `OptError("Expected switch argument")`. Example code

var OptionParser = require('optparse').OptionParser;

var parser = new OptionParser([['-e', '--example STRING']]);
parser.parse(['--example', '--test']);

This does as you would expect and throws. However, calling `parser.parse(['--example']);` will not throw even though the argument to `example` is mandatory and missing. This is because the `arg` is `undefined` so neither `LONG_SWITCH_RE` nor `SHORT_SWITCH_RE` match it.