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

Somewhat non-intuitive flag conversion to semantic type #208

Closed
JakeWharton opened this issue Jul 22, 2020 · 0 comments · Fixed by #210
Closed

Somewhat non-intuitive flag conversion to semantic type #208

JakeWharton opened this issue Jul 22, 2020 · 0 comments · Fixed by #210

Comments

@JakeWharton
Copy link

I have a --debug flag and rather than litter my codebase with conditionals on a boolean I want to have this return Debug.Console when set and otherwise have a default of Debug.Disabled. As far as I can tell, this isn't supported by flag().

I first looked at mutuallyExclusiveOptions(option("--debug").convert { Debug.Console }).default(Debug.Disabled), but this fails to compile as at least two options are required.

Thankfully I found option().switch<Debug>(mapOf("--debug" to Debug.Console)).default(Debug.Disabled), although it took a while.

Is it worth putting a convert extension onto FlagOption?

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 a pull request may close this issue.

1 participant