mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 22:54:39 +00:00
Remove unused code in Argument::validate
As far as I can tell, this statement is never true. When m_values.size() < *expected, ::consume has already thrown "Too few arguments..." before ::validate is called. When m_values.size() > *expected, ArgumentParser::parse_args_internal has already thrown "Maximum number of positional arguments exceeded" before ::validate is called. If ::remaining is used to avoid the last exception, this Argument will always consume the expected number of values, hence this expression is again false. Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This commit is contained in:
parent
b9dd1ef8e3
commit
37a1f3b9e6
@ -518,13 +518,6 @@ public:
|
||||
void validate() const {
|
||||
if (auto expected = maybe_nargs()) {
|
||||
if (m_is_optional) {
|
||||
if (m_is_used && m_values.size() != *expected && !m_is_repeatable &&
|
||||
!m_default_value.has_value()) {
|
||||
std::stringstream stream;
|
||||
stream << m_used_name << ": expected " << *expected
|
||||
<< " argument(s). " << m_values.size() << " provided.";
|
||||
throw std::runtime_error(stream.str());
|
||||
}
|
||||
// TODO: check if an implicit value was programmed for this argument
|
||||
if (!m_is_used && !m_default_value.has_value() && m_is_required) {
|
||||
std::stringstream stream;
|
||||
|
Loading…
Reference in New Issue
Block a user