mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 15:14:39 +00:00
Fix incorrect message when mUsedName is empty
Previously, it printed ": expected 1 argument(s). 0 provided." when one positional argument is defined but nothing is provided. Now it prints "1 argument(s) expected. 0 provided."
This commit is contained in:
parent
176da54c9b
commit
43f4629be5
@ -452,8 +452,10 @@ public:
|
|||||||
} else {
|
} else {
|
||||||
if (mValues.size() != expected && !mDefaultValue.has_value()) {
|
if (mValues.size() != expected && !mDefaultValue.has_value()) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << mUsedName << ": expected " << *expected << " argument(s). "
|
if (!mUsedName.empty())
|
||||||
<< mValues.size() << " provided.";
|
stream << mUsedName << ": ";
|
||||||
|
stream << *expected << " argument(s) expected. " << mValues.size()
|
||||||
|
<< " provided.";
|
||||||
throw std::runtime_error(stream.str());
|
throw std::runtime_error(stream.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user