diff --git a/CHANGELOG.md b/CHANGELOG.md index f1f52fe8..eaee48dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ -## In progress +## Version 1.5: Optional -This version has some internal cleanup and improved support for the newest compilers. + +This version introduced support for optionals, along with clarification and examples of custom conversion overloads. Enums now have been dropped from the automatic conversion system, allowing explicit protection for out-of-range ints (or a completely custom conversion). This version has some internal cleanup and improved support for the newest compilers. Several bugs were fixed, as well. Note: This is the final release with `requires`, please switch to `needs`. diff --git a/README.md b/README.md index 437208ae..8eebc051 100644 --- a/README.md +++ b/README.md @@ -388,7 +388,8 @@ Significant features and/or improvements to the code were contributed by: * [Lucas Czech](https://github.com/lczech) * [Mathias Soeken](https://github.com/msoeken) * [Nathan Hourt](https://github.com/nathanhourt) - +* [Stéphane Del Pino](https://github.com/delpinux) +* [Anton](https://github.com/SX91) CLI11 was developed at the [University of Cincinnati] to support of the [GooFit] library under [NSF Award 1414736]. Version 0.9 was featured in a [DIANA/HEP] meeting at CERN ([see the slides][DIANA slides]). Please give it a try! Feedback is always welcome. diff --git a/tests/AppTest.cpp b/tests/AppTest.cpp index 0b1c2416..c9fad4d6 100644 --- a/tests/AppTest.cpp +++ b/tests/AppTest.cpp @@ -1458,3 +1458,21 @@ TEST_F(TApp, ThrowingTransform) { EXPECT_EQ(e.what(), std::string("--mess: My Message")); } } + +// #87 +TEST_F(TApp, CustomDoubleOption) { + + std::pair custom_opt; + + auto opt = app.add_option("posit", [&custom_opt](CLI::results_t vals) { + custom_opt = {stol(vals.at(0)), stod(vals.at(1))}; + return true; + }); + opt->set_custom_option("INT FLOAT", 2); + + args = {"12", "1.5"}; + + run(); + EXPECT_EQ(custom_opt.first, 12); + EXPECT_FLOAT_EQ(custom_opt.second, 1.5); +} diff --git a/tests/HelpTest.cpp b/tests/HelpTest.cpp index 52b566af..d8b64b25 100644 --- a/tests/HelpTest.cpp +++ b/tests/HelpTest.cpp @@ -461,3 +461,19 @@ TEST_F(CapturedHelp, RepacedError) { EXPECT_THAT(err.str(), HasSubstr("Thing")); EXPECT_THAT(err.str(), HasSubstr("Usage")); } + +// #87 +TEST(THelp, CustomDoubleOption) { + + std::pair custom_opt; + + CLI::App app; + + auto opt = app.add_option("posit", [&custom_opt](CLI::results_t vals) { + custom_opt = {stol(vals.at(0)), stod(vals.at(1))}; + return true; + }); + opt->set_custom_option("INT FLOAT", 2); + + EXPECT_THAT(app.help(), Not(HasSubstr("x 2"))); +}