Skip to content

Commit 2489225

Browse files
committed
made clear what is being checked
1 parent 54296ca commit 2489225

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

argparse.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,14 @@ class ArgumentParser {
119119
if (!_help) {
120120
for (auto &a : _arguments) {
121121
if (a._required) {
122-
if (_variables.find(a._name) == _variables.end()
123-
&& (_pairs.find(a._name) == _pairs.end() || _variables.find(_pairs.find(a._name)->second) == _variables.end())) {
124-
throw ArgumentNotFound(a, _pairs);
122+
if (_variables.find(a._name) == _variables.end()) {
123+
// Check if a pair name does not exist. If it does exist check that
124+
// there is not a variable with that name
125+
if (_pairs.find(a._name) == _pairs.end() ||
126+
_variables.find(_pairs.find(a._name)->second) ==
127+
_variables.end()) {
128+
throw ArgumentNotFound(a, _pairs);
129+
}
125130
}
126131
}
127132
}

0 commit comments

Comments
 (0)