feat(command): builder function no longer needs to return the yargs instance #549
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 theyargs
instance 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
yargs
instance, 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 handler
unit test because this change breaks it and it no longer seems to be valid (options must now be markedglobal: true
in 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. 😎