Skip to content

Commit

Permalink
Merge pull request #216 from abbr/abbr_bugfix
Browse files Browse the repository at this point in the history
Add support for double dash option terminator
  • Loading branch information
thethomaseffect committed Jul 28, 2014
2 parents 4e839c2 + fa3aa3f commit 3242851
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ Command.prototype.normalize = function(args){
lastOpt = this.optionFor(args[i-1]);
}

if (lastOpt && lastOpt.required) {
if(arg==='--'){
// honor option terminator
ret = ret.concat(args.slice(i));
break;
} else if (lastOpt && lastOpt.required) {
ret.push(arg);
} else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) {
arg.slice(1).split('').forEach(function(c){
Expand Down
3 changes: 2 additions & 1 deletion test/test.options.hyphen.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ program
.option('-b, --bravo <b>', 'hyphen')
.option('-c, --charlie <c>', 'hyphen')

program.parse('node test -a - --bravo - --charlie=- - -- -'.split(' '));
program.parse('node test -a - --bravo - --charlie=- - -- - -t1'.split(' '));
program.alpha.should.equal('-');
program.bravo.should.equal('-');
program.charlie.should.equal('-');
program.args[0].should.equal('-');
program.args[1].should.equal('-');
program.args[2].should.equal('-t1');

0 comments on commit 3242851

Please sign in to comment.