From 801e0ad1cf544d08d93c6c52d869dd1e82030dbf 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 --- README.md | 2 +- examples/CMakeLists.txt | 2 +- include/CLI/App.hpp | 8 +++++++- tests/AppTest.cpp | 13 +++++++++++++ tests/SubcommandTest.cpp | 2 +- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8eebc0513..f9eaaf9d0 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 f3911d0b7..c6851229d 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 543b85a19..ff9852260 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