mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-06 07:03:52 +00:00
Adding check for -2 opts
This commit is contained in:
parent
1b3a4b63c8
commit
6638549adb
@ -1370,7 +1370,6 @@ class App {
|
|||||||
|
|
||||||
int num = op->get_expected();
|
int num = op->get_expected();
|
||||||
|
|
||||||
/// ONE ///////////////////////////////////////////////////////////////
|
|
||||||
if(!value.empty()) {
|
if(!value.empty()) {
|
||||||
if(num != -1)
|
if(num != -1)
|
||||||
num--;
|
num--;
|
||||||
@ -1409,8 +1408,8 @@ class App {
|
|||||||
args.pop_back();
|
args.pop_back();
|
||||||
collected++;
|
collected++;
|
||||||
}
|
}
|
||||||
// if(collected < -num)
|
if(op->results_.size() < static_cast<size_t>(-num))
|
||||||
// throw ArgumentMismatch(op->single_name() + ": At least " + std::to_string(-num) + " required");
|
throw ArgumentMismatch(op->single_name() + ": At least " + std::to_string(-num) + " required");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
while(num > 0 && !args.empty()) {
|
while(num > 0 && !args.empty()) {
|
||||||
|
@ -338,7 +338,7 @@ TEST_F(TApp, RequiredOptsUnlimited) {
|
|||||||
app.add_option("--str", strs)->required();
|
app.add_option("--str", strs)->required();
|
||||||
|
|
||||||
args = {"--str"};
|
args = {"--str"};
|
||||||
EXPECT_THROW(run(), CLI::RequiredError);
|
EXPECT_THROW(run(), CLI::ArgumentMismatch);
|
||||||
|
|
||||||
app.reset();
|
app.reset();
|
||||||
args = {"--str", "one", "--str", "two"};
|
args = {"--str", "one", "--str", "two"};
|
||||||
@ -372,7 +372,7 @@ TEST_F(TApp, RequiredOptsUnlimitedShort) {
|
|||||||
app.add_option("-s", strs)->required();
|
app.add_option("-s", strs)->required();
|
||||||
|
|
||||||
args = {"-s"};
|
args = {"-s"};
|
||||||
EXPECT_THROW(run(), CLI::RequiredError);
|
EXPECT_THROW(run(), CLI::ArgumentMismatch);
|
||||||
|
|
||||||
app.reset();
|
app.reset();
|
||||||
args = {"-s", "one", "-s", "two"};
|
args = {"-s", "one", "-s", "two"};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user