Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing argument validation on last option #14

Merged
merged 2 commits into from
Mar 22, 2014

Conversation

sabberworm
Copy link
Contributor

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.

jfd added a commit that referenced this pull request Mar 22, 2014
Fix missing argument validation on last option
@jfd jfd merged commit 0c48456 into jfd:master Mar 22, 2014
@jfd
Copy link
Owner

jfd commented Mar 22, 2014

Thanks

@sabberworm sabberworm deleted the throw-error-on-last-rule branch April 9, 2014 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants