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

Fleshing out parseArgs to support withValue and Multiples options #9

Merged
merged 8 commits into from
Oct 4, 2021

Conversation

JessNah
Copy link
Collaborator

@JessNah JessNah commented Sep 28, 2021

Added support for multiples option and withValue option case mentioned here nodejs/node#35015

**The Requirement of = for Options Expecting a Value**
For example, one may argue that --foo=bar should be the only way to use the value bar 
for the option foo; but users of CLI apps built on Node.js expect --foo bar to work just as well. 

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.

Jessica Nahulan and others added 4 commits September 23, 2021 20:06
…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
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 JessNah changed the title Fleshing out parseArgs for withValue and Multiples options Fleshing out parseArgs to support withValue and Multiples options Sep 28, 2021
index.js Outdated Show resolved Hide resolved
@JessNah JessNah requested a review from ljharb September 28, 2021 15:37
@joesepi
Copy link
Collaborator

joesepi commented Sep 28, 2021

For some context: @JessNah was using the examples here to help guide this implementation: https://github.com/pkgjs/parseargs#examples-w-output

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants