jfd/optparse-js — pull request #15 by sabberworm (2014-03-19 11:25:21+00:00)
Title: Pass the list of unparsed tokens to the filter

This is not a bugfix but a feature request. I wanted to be able to have an option that accepts multiple arguments. With this change, I’m able to write a filter for this:

var parser = new OptionParser([['-e', '--example ARRAY']]);

parser.filter('array', function(arg, tokens) {
var result = [arg];
var token;
while((token = tokens.shift()) && token.indexOf('-') !== 0) {
result.push(token);
}
if(token) {
tokens.unshift(token);
}
return result;
});