From 8f1215873c8f5aa2c82c89294e4874ebd071817d Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Mon, 9 Apr 2018 13:17:55 +0200 Subject: [PATCH] Allow -- to end unlimited options --- CHANGELOG.md | 7 +++++-- README.md | 2 +- examples/CMakeLists.txt | 2 +- include/CLI/App.hpp | 8 +++++++- tests/AppTest.cpp | 13 +++++++++++++ tests/SubcommandTest.cpp | 2 +- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaee48dd..9e8e3dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,4 @@ -## Version 1.5: Optional - +## Version 1.5: Optionals 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. @@ -11,6 +10,7 @@ Note: This is the final release with `requires`, please switch to `needs`. * All macros/CMake variables now start with `CLI11_` instead of just `CLI_` [#95] * The internal stream was not being cleared before use in some cases. Fixed. [#95] * Using an emum now requires explicit conversion overload [#97] +* The separator `--` now is removed when it ends unlimited arguments [#100] Other, non-user facing changes: @@ -21,12 +21,15 @@ Other, non-user facing changes: * Better single file generation [#95] * Added support for GTest on MSVC 2017 (but not in C++17 mode, will need next version of GTest) * Types now have a specific size, separate from the expected number - cleaner and more powerful internally [#92] +* Examples now run as part of testing [#99] [#64]: https://github.com/CLIUtils/CLI11/issues/64 [#90]: https://github.com/CLIUtils/CLI11/issues/90 [#92]: https://github.com/CLIUtils/CLI11/issues/92 [#95]: https://github.com/CLIUtils/CLI11/pull/95 [#97]: https://github.com/CLIUtils/CLI11/pull/97 +[#99]: https://github.com/CLIUtils/CLI11/pull/99 +[#100]: https://github.com/CLIUtils/CLI11/pull/100 ## Version 1.4: More feedback diff --git a/README.md b/README.md index 8eebc051..f9eaaf9d 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ On a compiler that supports C++17's `__has_include`, you can also use `std::opti The add commands return a pointer to an internally stored `Option`. If you set the final argument to true, the default value is captured and printed on the command line with the help flag. This option can be used directly to check for the count (`->count()`) after parsing to avoid a string based lookup. Before parsing, you can set the following options: * `->required()`: The program will quit if this option is not present. This is `mandatory` in Plumbum, but required options seems to be a more standard term. For compatibility, `->mandatory()` also works. -* `->expected(N)`: Take `N` values instead of as many as possible, only for vector args. If negative, require at least `-N`. +* `->expected(N)`: Take `N` values instead of as many as possible, only for vector args. If negative, require at least `-N`; end with `--` or another recognized option. * `->needs(opt)`: This option requires another option to also be present, opt is an `Option` pointer. * `->excludes(opt)`: This option cannot be given with `opt` present, opt is an `Option` pointer. * `->envname(name)`: Gets the value from the environment if present and not passed on the command line. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f3911d0b..c6851229 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -65,7 +65,7 @@ add_cli_exe(prefix_command prefix_command.cpp) add_test(NAME prefix_command COMMAND prefix_command -v 3 2 1 -- other one two 3) set_property(TEST prefix_command PROPERTY PASS_REGULAR_EXPRESSION "Prefix: 3 : 2 : 1" - "Remaining commands: -- other one two 3") + "Remaining commands: other one two 3") add_cli_exe(enum enum.cpp) add_test(NAME enum_pass COMMAND enum -l 1) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 543b85a1..349a0d5d 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -1035,12 +1035,14 @@ class App { /// This gets a vector of pointers with the original parse order const std::vector