-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
isMultiple string flag is matching also the input arguments #160
Comments
// @ulken |
Haven't looked at the code, but as I recall we allow ( As I see it, we have two options:
How do we want this to work? |
Not sure if it would work, but maybe require wrapping the argument in quotes if one wants to space separate values? Then we could only consume the first argument and split it on whitespace. |
I won't have a look at it until it's been decided what the desired behavior is here. |
When I submitted the bug, I didn't know that this was the expected behavior. It seems that yargs works in a similar way with array flags. I can workaround my CLI app by splitting a single value flag. I understand if there is no desire to change it. As user of the CLI I found this behavior to be unexpected, because double dash usually means do not parse the rest. My expectation for the multiple flag was something like: It's ok for me to close the bug, if the behavior is by design. |
Yes, you're right regarding The examples you list should still work though. Or are you saying it parses |
@sindresorhus What say you? Change or close? |
I must have missed that when merging the PR. I agree, with @dfernandez79 that it's not what the user would expect, and neither would I. |
👍🏻 I think it's worth doing a major release to fix this. |
Then I apologize for introducing it. No excuse, but I got it from one of the previous PR attempts. |
@ulken I was not blaming you, FWIW. |
Fixed the first half of the issue, i.e. not greedily consume array flag arguments. I'll make a separate PR for supporting comma-separated values. |
Gave it a go, but did not end up well. I could easily make it work for I used the |
Open issue in |
If we really want to support comma separated values, I suppose we could convert all array types to |
No, that's not a viable option either. It ends being really brittle having to handle defaults etc. (apart from handling type coercion). |
Nah. We can wait for Yargs to implement it: #164 |
I have a flag (called
multiple
) with a stringtype
and theisMultiple
flag. When I use that flag with an input argument, the input argument is now part of the flag values. This doesn't happen if you put the flag at the end.Example code
Test repo: https://github.com/dfernandez79/ismultiple-flag-example
Outputs
The text was updated successfully, but these errors were encountered: