Commit 20f881f6923f71c59b782367caa2ef606b954264
1 parent
19f8da61
Adding better error messages, Xcode folders
Showing
2 changed files
with
13 additions
and
5 deletions
cmake/AddGoogletest.cmake
| @@ -50,16 +50,16 @@ macro(add_gtest TESTNAME) | @@ -50,16 +50,16 @@ macro(add_gtest TESTNAME) | ||
| 50 | gtest_add_tests(TARGET ${TESTNAME} | 50 | gtest_add_tests(TARGET ${TESTNAME} |
| 51 | TEST_PREFIX "${TESTNAME}." | 51 | TEST_PREFIX "${TESTNAME}." |
| 52 | TEST_LIST TmpTestList) | 52 | TEST_LIST TmpTestList) |
| 53 | - set_tests_properties(${TmpTestList} PROPERTIES FOLDER "Tests") | ||
| 54 | else() | 53 | else() |
| 55 | gtest_discover_tests(${TESTNAME} | 54 | gtest_discover_tests(${TESTNAME} |
| 56 | TEST_PREFIX "${TESTNAME}." | 55 | TEST_PREFIX "${TESTNAME}." |
| 57 | - PROPERTIES FOLDER "Tests") | 56 | + ) |
| 57 | + | ||
| 58 | endif() | 58 | endif() |
| 59 | else() | 59 | else() |
| 60 | add_test(${TESTNAME} ${TESTNAME}) | 60 | add_test(${TESTNAME} ${TESTNAME}) |
| 61 | - set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") | ||
| 62 | endif() | 61 | endif() |
| 62 | + set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests") | ||
| 63 | 63 | ||
| 64 | endmacro() | 64 | endmacro() |
| 65 | 65 |
include/CLI/App.hpp
| @@ -1105,8 +1105,16 @@ class App { | @@ -1105,8 +1105,16 @@ class App { | ||
| 1105 | // Verify required options | 1105 | // Verify required options |
| 1106 | for(const Option_p &opt : options_) { | 1106 | for(const Option_p &opt : options_) { |
| 1107 | // Required | 1107 | // Required |
| 1108 | - if(opt->get_required() && (static_cast<int>(opt->count()) < opt->get_expected() || opt->count() == 0)) | ||
| 1109 | - throw RequiredError(opt->get_name()); | 1108 | + if(opt->get_required()) { |
| 1109 | + if(opt->count() == 0) { | ||
| 1110 | + throw RequiredError(opt->get_name() + " is required"); | ||
| 1111 | + } else if (static_cast<int>(opt->count()) < opt->get_expected()) { | ||
| 1112 | + if(opt->get_expected() == 1) | ||
| 1113 | + throw RequiredError(opt->get_name() + " requires an argument"); | ||
| 1114 | + else | ||
| 1115 | + throw RequiredError(opt->get_name() + " requires at least " + std::to_string(opt->get_expected()) + " arguments"); | ||
| 1116 | + } | ||
| 1117 | + } | ||
| 1110 | // Requires | 1118 | // Requires |
| 1111 | for(const Option *opt_req : opt->requires_) | 1119 | for(const Option *opt_req : opt->requires_) |
| 1112 | if(opt->count() > 0 && opt_req->count() == 0) | 1120 | if(opt->count() > 0 && opt_req->count() == 0) |