Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Array valued options #2

Merged
merged 1 commit into from

3 participants

@dhruvbird

Allow array valued options. For example:

$ node summer.js --n=1 --n=3 --n=8 --n=2

@dhruvbird dhruvbird In case the default value of a parameter is an array, append values t…
…hat the user passes on the command line into the array. Allows stuff like: $ node script.js --file=FILE1 --file=FILE2 --file=FILE3 ...
b61a494
@akaspin akaspin merged commit 01e2050 into akaspin:master
@dhruvbird

Thanks!

@dhruvbird

Can you please re-publish to npm with a new version number (since I use it in package.json everywhere)?

@akaspin
Owner

Ohh. It will be quite a chore. I no longer developed for node.js.

@dhruvbird

okay - no problem - can you transfer ownership or something so that I can publish? If not, I can always publish the same under a different name. Either ways, please do let me know - thanks!

@akaspin
Owner

Ok. Just kick me to description - how to transfer ownership?

@dhruvbird

You can do:
npm owner add dhruvbird tav
and hope that works. If not, let me know. I am assuming that your creds. are saved in ~/.npmrc.

@dhruvbird

bump.

@isaacs

Qv email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 31, 2012
  1. @dhruvbird

    In case the default value of a parameter is an array, append values t…

    dhruvbird authored
    …hat the user passes on the command line into the array. Allows stuff like: $ node script.js --file=FILE1 --file=FILE2 --file=FILE3 ...
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 index.js
View
6 index.js
@@ -118,7 +118,11 @@ Object.defineProperty(tav, "set", {
value = parseFloat(value);
}
}
- self[name] = value;
+ if (self[name] instanceof Array) {
+ self[name].push(value);
+ } else {
+ self[name] = value;
+ }
} else {
// Just argument
self.args.push(chunk);
Something went wrong with that request. Please try again.