diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 4d383565..0cbe4944 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -351,16 +351,16 @@ class App { return opt; } - /// Bool version only allows the flag once + /// Bool version template ::value, detail::enabler> = detail::dummy> Option *add_flag(std::string name, T &count, ///< A varaible holding true if passed std::string description = "") { count = false; - CLI::callback_t fun = [&count](CLI::results_t res) { + CLI::callback_t fun = [&count](CLI::results_t) { count = true; - return res.size() == 1; + return true; }; Option *opt = add_option(name, fun, description, false); diff --git a/tests/AppTest.cpp b/tests/AppTest.cpp index 26b74f97..4d2ff049 100644 --- a/tests/AppTest.cpp +++ b/tests/AppTest.cpp @@ -154,7 +154,8 @@ TEST_F(TApp, BoolAndIntFlags) { app.reset(); args = {"-b", "-b"}; - EXPECT_THROW(run(), CLI::ConversionError); + EXPECT_NO_THROW(run()); + EXPECT_TRUE(bflag); app.reset(); bflag = false; diff --git a/tests/IniTest.cpp b/tests/IniTest.cpp index ccc48063..b21e9168 100644 --- a/tests/IniTest.cpp +++ b/tests/IniTest.cpp @@ -438,7 +438,8 @@ TEST_F(TApp, IniFlagNumbers) { out << "flag=3" << std::endl; } - EXPECT_THROW(run(), CLI::ConversionError); + EXPECT_NO_THROW(run()); + EXPECT_TRUE(boo); } TEST_F(TApp, IniFlagDual) {