substack/node-optimist — pull request #98 by drj11 (2013-05-17 15:29:58+00:00)
Title: Adds .posix() function.

optimist currently continues parsing options even when it's found something that isn't an option. This violates the POSIX guidelines for parsing options, which some tools follow.

For example, consider xargs:

xargs -n 2 cp -p

In this case "cp -p" are the arguments, and -p is an option that supposed to be passed to cp, not consumed by xargs.

So now you can add a call to .posix() which causes optimist to adopt the POSIX behaviour and stop processing options on the first non-option.

Like this:

argv = require('optimist').posix()
.boolean('p', 't', 'x').string('E').argv

Am prepared to add some documentation and tests if you're prepared to accept in principle.