Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated options #198

Merged
merged 2 commits into from
Mar 29, 2014
Merged

Repeated options #198

merged 2 commits into from
Mar 29, 2014

Conversation

AlphaHydrae
Copy link
Contributor

The first commit in test.options.commands.js fixes a test that was failing when I cloned the repo.

The second commit allows to collect values through coercion functions by making the previous option value available to those functions. See the tests I have added and the examples in examples/coercion.

@ming-codes
Copy link

I just thought of this, then I saw this pull request. 👍

@@ -324,7 +324,7 @@ Command.prototype.option = function(flags, description, fn, defaultValue){
// and conditionally invoke the callback
this.on(oname, function(val){
// coercion
if (null != val && fn) val = fn(val);
if (null !== val && fn) val = fn(val, 'undefined' != typeof self[name] ? self[name] : defaultValue);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for typeof here, just undefined === or a hasOwnProperty

@AlphaHydrae
Copy link
Contributor Author

Just fixed the undefined check you commented on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants