-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fleshing out parseArgs to support withValue and Multiples options #9
Merged
Conversation
This file contains 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
…options This PR handles: 1. setting values for args only if the arg is specified in the options.withValue array 2. set arg value to undefined if withValue isn't specified 3. add args without a dashprefix to the positionals array 4. handle only recording the last value for the arg, in the case of multiple values set for same arg 5. in the case of multiple values set for the same arg, and 'multiples' options having been set, handle recording all values for the arg in the returned array 6. Introduces new test cases covering readme examples, withValue, multiples, and error throwing bad input cases
…ltiples options" This reverts commit 4486551.
This PR handles: 1. setting values for args only if the arg is specified in the options.withValue array 2. set arg value to undefined if withValue isn't specified 3. add args without a dashprefix to the positionals array 4. handle only recording the last value for the arg, in the case of multiple values set for same arg 5. in the case of multiple values set for the same arg, and 'multiples' options having been set, handle recording all values for the arg in the returned array 6. Introduces new test cases covering readme examples, withValue, multiples, and error throwing bad input cases
JessNah
changed the title
Fleshing out parseArgs for withValue and Multiples options
Fleshing out parseArgs to support withValue and Multiples options
Sep 28, 2021
ljharb
reviewed
Sep 28, 2021
…,0,null,nan,'' cases
For some context: @JessNah was using the examples here to help guide this implementation: https://github.com/pkgjs/parseargs#examples-w-output |
ljharb
approved these changes
Oct 1, 2021
bcoe
approved these changes
Oct 1, 2021
Co-authored-by: Jordan Harband <[email protected]>
Co-authored-by: Jordan Harband <[email protected]>
joesepi
approved these changes
Oct 4, 2021
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.
Added support for multiples option and withValue option case mentioned here nodejs/node#35015
Let me know if anyone thinks I should change lines 48, 58, 63 into some helper function or make it less concise and split the logic over several lines.
Thanks for the review & consideration.