File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,9 +37,11 @@ class ArgumentParser {
3737 public:
3838 class ArgumentNotFound : public std ::runtime_error {
3939 public:
40- ArgumentNotFound (ArgumentParser::Argument &arg) noexcept
40+ ArgumentNotFound (ArgumentParser::Argument &arg,
41+ std::unordered_map<std::string, std::string> pairs) noexcept
4142 : std::runtime_error(
42- (" Required argument not found: " + arg._name).c_str()) {}
43+ (" Required argument not found: " + arg._name + ((pairs.find(arg._name) == pairs.end())
44+ ? " " : " or " + pairs.find(arg._name)->second)).c_str()) {}
4345 };
4446
4547 ArgumentParser (const std::string &desc) : _desc(desc), _help(false ) {}
@@ -117,8 +119,9 @@ class ArgumentParser {
117119 if (!_help) {
118120 for (auto &a : _arguments) {
119121 if (a._required ) {
120- if (_variables.find (a._name ) == _variables.end ()) {
121- throw ArgumentNotFound (a);
122+ if (_variables.find (a._name ) == _variables.end ()
123+ && _variables.find (_pairs.find (a._name )->second ) == _variables.end ()) {
124+ throw ArgumentNotFound (a, _pairs);
122125 }
123126 }
124127 }
You can’t perform that action at this time.
0 commit comments