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

Investigate update to default capture #241

Closed
henryiii opened this issue Feb 27, 2019 · 0 comments · Fixed by #242
Closed

Investigate update to default capture #241

henryiii opened this issue Feb 27, 2019 · 0 comments · Fixed by #242

Comments

@henryiii
Copy link
Collaborator

henryiii commented Feb 27, 2019

Two things could possibly be added that I thought were impossible before:

A templated function could be added that converts a default value to a string only if it can be converted, and otherwise returns an empty string. This would enable the two versions of add_option overloads, one with bool defaulted and one without, to be combined into bool defaulted=false.

Second, the default string could instead be set as a lambda function that is stored in the Option. A new method, ->defaulted(), would run that lambda function to produce the default string. This would make the old bool option obsolete and is much more readable (but still would probably need to be supported until something like CLI11 2.0, since it would be very common in code). The bool option would simply run ->defaulted() on the option.

Maybe I'm missing something, but I think this could work...

I which I could use ->default, but it's a C++ keyword.

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