From 954c93d5856de034ed9c40eef1cc6bc63686226e Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Tue, 28 Nov 2017 13:27:41 -0500 Subject: [PATCH] Using more powerful policy system, to allow git-like -m options --- include/CLI/App.hpp | 5 +++-- include/CLI/Option.hpp | 47 +++++++++++++++++++++--------------------- tests/AppTest.cpp | 28 +++++++++++++++++++++++-- tests/CreationTest.cpp | 14 ++++++++----- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 861c901b..90b0d18f 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -394,7 +394,8 @@ class App { return opt; } - /// Bool version - defaults to allowing multiple passings, but can be forced to one if `take_last(false)` is used. + /// Bool version - defaults to allowing multiple passings, but can be forced to one if + /// `multi_option_policy(CLI::MultiOptionPolicy::Throw)` is used. template ::value, detail::enabler> = detail::dummy> Option *add_flag(std::string name, T &count, ///< A variable holding true if passed @@ -410,7 +411,7 @@ class App { if(opt->get_positional()) throw IncorrectConstruction("Flags cannot be positional"); opt->set_custom_option("", 0); - opt->take_last(); + opt->multi_option_policy(CLI::MultiOptionPolicy::TakeLast); return opt; } diff --git a/include/CLI/Option.hpp b/include/CLI/Option.hpp index 990440f6..76210cd1 100644 --- a/include/CLI/Option.hpp +++ b/include/CLI/Option.hpp @@ -26,6 +26,8 @@ class App; using Option_p = std::unique_ptr