Permalink
Browse files

opt keys are case insensitive but opt values and args are case sensit…

…ive.
  • Loading branch information...
1 parent 46e9379 commit ddb32ee011394beb7d43a62497c3d1811719123f @thatismatt committed Jun 7, 2010
Showing with 16 additions and 2 deletions.
  1. +2 −2 lib/josi/utilities.js
  2. +14 −0 tests/utilities.js
View
@@ -37,9 +37,9 @@ this.processARGV = function(argv) {
.forEach(function(arg) {
var match = optsRE.exec(arg);
if (match) {
- opts[match[1].toLowerCase()] = match[2].toLowerCase();
+ opts[match[1].toLowerCase()] = match[2];
} else {
- args.push(arg.toLowerCase());
+ args.push(arg);
}
});
return {
View
@@ -40,6 +40,20 @@ this.tests = {
var processed = utilities.processARGV(['', '', 'atask', 'arg']);
assert.equal(processed.args[0], 'arg');
},
+ 'Opt keys are case insensitive': function() {
+ var processed = utilities.processARGV(['', '', 'atask', 'CaMel=b', 'c=HumPs', 'third=alongerthing']);
+ assert.equal(processed.opts.camel, 'b');
+ assert.equal(processed.opts.c, 'HumPs');
+ assert.equal(processed.opts.third, 'alongerthing');
+ },
+ 'Opt values are case sensitive': function() {
+ var processed = utilities.processARGV(['', '', 'atask', 'CaMel=b']);
+ assert.equal(processed.opts.camel, 'b');
+ },
+ 'Args are case sensitive': function() {
+ var processed = utilities.processARGV(['', '', 'atask', 'HumPs']);
+ assert.equal(processed.args[0], 'HumPs');
+ },
'Multiple opts work': function() {
var processed = utilities.processARGV(['', '', 'atask', 'a=b', 'c=100', 'third=alongerthing']);
assert.equal(processed.opts.a, 'b');

0 comments on commit ddb32ee

Please sign in to comment.