Commit cef5dfa58d6c4e365229d378db6f34603be3215e

Authored by Henry Fredrick Schreiner
1 parent f5957032

Revert change for now, add helper function

Showing 1 changed file with 14 additions and 1 deletions
include/CLI/App.hpp
@@ -1064,6 +1064,19 @@ class App { @@ -1064,6 +1064,19 @@ class App {
1064 } 1064 }
1065 } 1065 }
1066 1066
  1067 + /// Count the required remaining positional arguments
  1068 + size_t _count_remaining_required_positionals() const {
  1069 + size_t retval = 0;
  1070 + for(const Option_p &opt : options_)
  1071 + if(opt->get_positional()
  1072 + && opt->get_required()
  1073 + && opt->get_expected() > 0
  1074 + && static_cast<int>(opt->count()) < opt->get_expected())
  1075 + retval = static_cast<size_t>(opt->get_expected()) - opt->count();
  1076 +
  1077 + return retval;
  1078 + }
  1079 +
1067 /// Parse a positional, go up the tree to check 1080 /// Parse a positional, go up the tree to check
1068 void _parse_positional(std::vector<std::string> &args) { 1081 void _parse_positional(std::vector<std::string> &args) {
1069 1082
@@ -1080,7 +1093,7 @@ class App { @@ -1080,7 +1093,7 @@ class App {
1080 } 1093 }
1081 } 1094 }
1082 1095
1083 - if(parent_ != nullptr && fallthrough_) 1096 + if(parent_ != nullptr)// TODO && fallthrough_)
1084 return parent_->_parse_positional(args); 1097 return parent_->_parse_positional(args);
1085 else { 1098 else {
1086 args.pop_back(); 1099 args.pop_back();