Repository navigation
feat(command): builder function no longer needs to return the yargs instance - #549
Merged
Merged
Conversation
|
|
||
| it('does not require builder function to return', function () { | ||
| var argv = yargs('yo') | ||
| .command('yo [someone]', 'Send someone a yo', function (yargs) { |
Member
There was a problem hiding this comment.
how is yo app doing, have they raised a 1 billion $$$ series B yet?
Member
|
Is the solution this simple, I could have sworn I thought of an edge-case that would bite us and forced the |
nexdrew
force-pushed
the
command-builder-no-return
branch
from
July 21, 2016 16:11
800ce3c to
7fcac0c
Compare
nexdrew
force-pushed
the
command-builder-no-return
branch
from
August 3, 2016 22:33
739a4f4 to
c3df213
Compare
…ssed into command handler` test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #522.
I'm not quite sure about the intentions of what should be allowed to be returned by the builder function. Returning theyargsinstance or nothing should now work, but I wonder if we ever intended to allow it to return something likeyargs.argv? If so, I think we will need a new issue for that.Otherwise, this PR seems to work fine, but it could possibly result in unexpected behavior in user CLIs if they were previously not returning the
yargsinstance, either by mistake or not. For that reason, this change may be better suited for 5.x.Note that I skipped the
populates argv with placeholder keys when passed into command handlerunit test because this change breaks it and it no longer seems to be valid (options must now be markedglobal: truein order to apply to the argv of a command handler, be it a placeholder or populated value). We should either remove it (if everyone agrees the test is no longer valid), or fix it by usingglobal: true(which is tested elsewhere).UPDATE: With commit 739a4f4, a builder function can also call
yargs.argv, with or without returning. I think this is a good idea b/c I've seen a few folks try to do this and it makes the API much less rigid. 😎