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

conversion error on multiple bool flagse #35

Closed
lambdafu opened this issue Nov 4, 2017 · 3 comments
Closed

conversion error on multiple bool flagse #35

lambdafu opened this issue Nov 4, 2017 · 3 comments
Labels
Milestone

Comments

@lambdafu
Copy link
Contributor

lambdafu commented Nov 4, 2017

When using a bool flag, giving the option multiple times on the command line causes a conversion error (because it can not count the number of times the option appears in a bool variable, I presume).

But that error message is ugly and user-unfriendly, so why would anybody ever use that? Which means everybody will just use an int and check for == 0.

Why not just keep the value at true and ignore the extraneous appearances of the bool flag on the command line?

Test case is in AppTest.cpp:156:

    args = {"-b", "-b"};
    EXPECT_THROW(run(), CLI::ConversionError);
@henryiii
Copy link
Collaborator

henryiii commented Nov 4, 2017

My (original) thinking is that int means multiple flags and bool one; you could then do: if(flag) to see if there are one or more. However, I think you are probably right. It's uncommon to want multiple flags to fail, and custom logic could be added to the int versions or the callback version.

@henryiii henryiii added this to the v1.3 milestone Nov 4, 2017
@lambdafu
Copy link
Contributor Author

lambdafu commented Nov 4, 2017

The way this works in GNU projects is that sometimes there is a corresponding --no-FLAG option that sets it to false, and the last one of --foo, --no-foo on the command line wins.

@lambdafu
Copy link
Contributor Author

Yep, #38 works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants