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

Add FlagOption.convert #210

Merged
merged 3 commits into from Jul 22, 2020
Merged

Add FlagOption.convert #210

merged 3 commits into from Jul 22, 2020

Conversation

ajalt
Copy link
Owner

@ajalt ajalt commented Jul 22, 2020

The semantics of this are different from OptionWithValues.convert. The latter conversion is called one for each occurrence of the option on the command line, while this flag conversion uses transformAll, and so is only called once with the final value of the flag.

We could have added a ValueTransformer field to FlagOption to make the semantics match, but that wouldn't be backwards compatible. I don't think it makes much sense for flags to have a value transformer anyway; this design feels more intuitive.

Fixes #208

Copy link

@JakeWharton JakeWharton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ajalt ajalt merged commit 362e799 into master Jul 22, 2020
@ajalt ajalt deleted the flag-convert branch July 22, 2020 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Somewhat non-intuitive flag conversion to semantic type
2 participants