-
Notifications
You must be signed in to change notification settings - Fork 68
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
feat: add 'multipleNonGreedy' flag option to assign only one value per multiple flag #880
Conversation
Thanks for the contribution! Before we can merge this, we need @royra to sign the Salesforce Inc. Contributor License Agreement. |
multiple flags such as `-f` were not parsed correctly due to a bug or misfeature in oclif. - update oclif to the latest version with the minimal required changes - create a patch from oclif/core#880 to fix oclif's behavior
@royra Thanks for the PR! Can you help me understand why someone would use |
This solves the problem with combining Example: assuming command -m val arg1 should parse into {
flags: { m: ['val'] },
args: { argOne: 'arg1' },
} but instead parses I simply ported the original PR, and I agree |
@mdonnalley I tried to sign the CLA and got some kind of server error. When trying again I'm getting a "already signed the CLA" message, but the GH check hasn't passed. Is there anything I can do to fix it? |
Related: #496 |
@royra Thanks but I'm still not sure I understand how this new property solves anything I understand the problem though. You want to be able to write a command that takes arguments and multi flags and have it parsed properly. But if you're adding a new property to force the parser to stop looking for flag values after it finds the first one, then why not just define the flag as non multi flag? As I understand it these two flag definitions are the exactly the same: flag1: Flags.string({
multiple: true,
singleValue: true,
}) flag1: Flags.string() Because of that, I'm not inclined to move forward with this PR as it is. My recommendations are:
|
This definition doesn't allow for specifying the flag more than once, e.g, Specifying a flag multiple times is a common pattern; unix classics like |
@royra Okay, I understand now. You want to allow In that case, I'd like for Thanks! |
@mdonnalley Done. Thank you! |
This is a port of oclif/parser#79 by @cxam
Original description:
This feature aims to address the issue outlined in oclif/oclif#190 to only allow a single value to be assigned for each flag that has the
multiple
option set. It's a non-breaking change that requires you to include thesingleValue
boolean in your flag options.In the command
cmd -a foo bar
, it's generally accepted thatbar
becomes a positional argument and should be the default behaviour. Unfortunately, the PR that broke default behaviour has been part of this project for a while now and I feel providing the user an option to change this back would be the best course of action unless a breaking release is planned for oclif.If this goes through, I'll update and push the relevant changes to the docs repository.