Removed brackets and quotes in error message

This commit is contained in:
Pranav Srinivas Kumar 2023-11-03 22:12:00 -05:00
parent 4111905a74
commit 78ba5e9828
2 changed files with 4 additions and 10 deletions

View File

@ -827,9 +827,6 @@ public:
std::string get_usage_full() const {
std::stringstream usage;
if (!m_is_required) {
usage << "[";
}
usage << get_names_csv();
const std::string metavar = !m_metavar.empty() ? m_metavar : "VAR";
if (m_num_args_range.get_max() > 0) {
@ -838,9 +835,6 @@ public:
usage << "...";
}
}
if (!m_is_required) {
usage << "]";
}
return usage.str();
}
@ -1833,8 +1827,8 @@ private:
if (not_help_or_version) {
if (!opt.m_is_used) {
throw std::runtime_error(
"Zero positional arguments expected, did you mean '" +
opt.get_usage_full() + "'");
"Zero positional arguments expected, did you mean " +
opt.get_usage_full());
}
}

View File

@ -23,14 +23,14 @@ TEST_CASE("Missing optional argument name" * test_suite("error_reporting")) {
SUBCASE("Bad case") {
REQUIRE_THROWS_WITH_AS(
parser.parse_args({"test", "-a", "1", "2"}),
"Zero positional arguments expected, did you mean '[-b VAR]'",
"Zero positional arguments expected, did you mean -b VAR",
std::runtime_error);
}
SUBCASE("Bad case 2") {
REQUIRE_THROWS_WITH_AS(
parser.parse_args({"test", "1", "2"}),
"Zero positional arguments expected, did you mean '[-a VAR]'",
"Zero positional arguments expected, did you mean -a VAR",
std::runtime_error);
}
}