Include canonical argument name in nargs range validation error

The name of a positional argument is never used.

Closes #208

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This commit is contained in:
Sean Robinson 2022-09-23 07:44:33 -07:00
parent 997da92556
commit 2a15178bb7
2 changed files with 3 additions and 1 deletions

View File

@ -758,6 +758,8 @@ private:
std::stringstream stream;
if (!m_used_name.empty()) {
stream << m_used_name << ": ";
} else {
stream << m_names.front() << ": ";
}
if (m_num_args_range.is_exact()) {
stream << m_num_args_range.get_min();

View File

@ -18,7 +18,7 @@ TEST_CASE("Missing expected positional argument" *
argparse::ArgumentParser program("test");
program.add_argument("input");
REQUIRE_THROWS_WITH_AS(program.parse_args({"test"}),
"1 argument(s) expected. 0 provided.",
"input: 1 argument(s) expected. 0 provided.",
std::runtime_error);
}