-
Notifications
You must be signed in to change notification settings - Fork 308
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
Allow passing value starting with - to custom option #192
Conversation
Revert this commit once jessevdk/go-flags#192 has been merged into go-flags. [#127131179] Signed-off-by: Anand Gaitonde <agaitonde@pivotal.io>
I don't like to special case this for custom options only. If this should be supported, then I think it should be supported for all options. The reason this is not the case, is because it leads to ambiguous parsing. In particular with flags that have an optional argument, we would need a different rule. Therefore, the decision has been that if you do need to specify a value starting with a |
@jessevdk I agree with your last point about the user intent being clear. But I think the same argument is valid on the use case @XenoPhex describes: the user there would be passing in
Or even for strings:
So the argument I'm trying to make here is that allowing |
any decisions on this? |
898f28b
to
5ce624e
Compare
Ok, your argument has convinced me. However, I would like that this works by adding a value validator for custom flags (i.e. |
Not really closed - I rebased incorrectly, will update shortly. |
@jessevdk Do you mean for |
I've updated the pull request with my best interpretation of what you said. Please let me know if it is correct. |
Sorry, what I meant was indeed an interface that a custom type may implement that can do validation of the option value. I did not mean that any custom type with a custom unmarshal will accept any kind of value. |
I'll resubmit this pull when I have some time later today. |
@jessevdk the adjustment has been submitted, please let me know if you need further changes! |
6cb61d5
to
dac4e0a
Compare
@jessevdk I've made the changes you've requested, but it looks like the Travis is failing on trying to get I also can't seem to retrigger the build. So... hoping you can take a stick to it and get it working. Tests & lint passed locally. |
This is blocked on #283. |
@jessevdk rebased the lint changes, let me know if there's anything more I can do. Thanks! |
Is this good to merge, @jessevdk? |
Hi @jessevdk, we are wondering if this PR can be merged? Thanks, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks!
Thanks for the merge!! |
We have a case where some of our custom flags for the Cloud Foundry CLI have string values that take
-1
as a value to signal special cases. For example, when we're setting a Maximum Allowed Memory Size (eg 1MB, 4GB, etc...) and we want this value to be unlimited, we use-1
.This pr will enable custom flags to take values with
-
.