Skip to content

Commit

Permalink
fixing bug in option parsing with flagged arguments and cake.
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Jul 11, 2010
1 parent be8d812 commit 4bd6571
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/optparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
for (_c = 0, _e = _d.length; _c < _e; _c++) {
rule = _d[_c];
if (rule.shortFlag === arg || rule.longFlag === arg) {
options[rule.name] = rule.hasArgument ? args[i + 1] : true;
options[rule.name] = rule.hasArgument ? args[i += 1] : true;
matchedRule = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/optparse.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exports.OptionParser: class OptionParser
matchedRule: no
for rule in @rules
if rule.shortFlag is arg or rule.longFlag is arg
options[rule.name]: if rule.hasArgument then args[i + 1] else true
options[rule.name]: if rule.hasArgument then args[i: + 1] else true
matchedRule: yes
break
throw new Error "unrecognized option: $arg" if isOption and not matchedRule
Expand Down
2 changes: 1 addition & 1 deletion test/test_option_parser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ result: opt.parse ['--optional', '-r', 'folder', 'one', 'two']

ok result.optional is true
ok result.required is 'folder'
ok result.arguments.join(' ') is 'folder one two'
ok result.arguments.join(' ') is 'one two'

0 comments on commit 4bd6571

Please sign in to comment.