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_option with bool? #224

Closed
abrownsword opened this issue Feb 15, 2019 · 7 comments
Closed

add_option with bool? #224

abrownsword opened this issue Feb 15, 2019 · 7 comments

Comments

@abrownsword
Copy link

I have a use case for being able to use this syntax: —option=true

Synonyms like yes/no or on/off would be nice. I have a hacked solution using a callback_t but I don’t see why bool isn’t a first class citizen?

@henryiii
Copy link
Collaborator

I believe this was added in #219 (will be in 1.8). It would be a flag.

@henryiii
Copy link
Collaborator

The only difference is that you can't force a value. --option=true and --option would be equivalent.

@phlptp
Copy link
Collaborator

phlptp commented Feb 15, 2019

I believe after #219 having bool value in add_option supports --option=true, --option disable and a number of other synonyms of true and false.

The difference between the add_option(XXX, bool) and add_flag(XXX, bool) is that in the option version an argument is required, in the flag version only the --option=<XX> syntax is supported but it has a default value so --option with no arguments uses a default value (usually true)

Adding a few more tests with add_option(XXX,bool,... would probably be good just to make sure

@abrownsword
Copy link
Author

I didn't see mention of this particular syntax in #219, but then again I'm on the last release, not on HEAD. I'll give it a go when the next release is posted.

@phlptp
Copy link
Collaborator

phlptp commented Feb 15, 2019

I don't think there was a syntax change as far as the options go, just internally it handles bool's in options consistently between flags, options and ini files, where there was some discrepancies before, at least that was the idea.

henryiii added a commit that referenced this issue Feb 18, 2019
@henryiii
Copy link
Collaborator

Added some tests in my Sets PR, it does look like this syntax now works. :)

henryiii added a commit that referenced this issue Feb 19, 2019
* Adding first draft of Sets

Use IsMember now

Using IsMember as backend for Set

Non-const validator backend

Move set tests to set

Clearer inits

* Drop shortcut

Tighten up classes a bit for MSVC

Check with GCC 4.8 too

* Simpler templates, but more of them

Dropping more type safety for older compilers

Shortcut string set

* Adding shortcut init

Making g++ 4.7 docker image happy

Fix Clang tidy issue with last commit

Adding one more shortcut, adding a couple of tests

* Dropping dual pointer versions of code

* Smarter shortcut syntax

* Adding slighly faster choices

* Cleanup to make InMember simpler

* Drop choices for now, adding some tests

* ValidationError is now always the error from a validator

* Support for other types of initializer lists, including enums

* Factor out type utilities, single version of IsMember code

* Adding a few tests for #224

* Minor cleanup for Validation Error

* Adding tests, moved deprecated tests

* Docs updates
@henryiii
Copy link
Collaborator

Tests are now part of master, and it's mentioned in the README and CHANGELOG, so I think it's okay to close this.

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

No branches or pull requests

3 participants