Skip to content

Commit

Permalink
auto number conversion works yay
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Dec 17, 2010
1 parent bcec56b commit 73dc901
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/optimist.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ function Argv (args, cwd) {

self.argv = { _ : [], $0 : self.$0 };

function set (key, value) {
function set (key, val) {
var num = Number(val);
var value = isNaN(num) ? val : num;

if (key in self.argv) {
if (!Array.isArray(self.argv[key])) {
self.argv[key] = [ self.argv[key] ];
Expand Down Expand Up @@ -96,7 +99,8 @@ function Argv (args, cwd) {
}
}
else {
self.argv._.push(arg);
var n = Number(arg);
self.argv._.push(isNaN(n) ? arg : n);
}
}

Expand Down

0 comments on commit 73dc901

Please sign in to comment.