1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-03 14:03:52 +00:00

Fixed error, but still have positional problem

This commit is contained in:
Henry Fredrick Schreiner 2017-01-26 15:37:00 -05:00
parent b935fcd129
commit 52e2a3db75

View File

@ -17,7 +17,7 @@
namespace { namespace {
void logit(std::string output) { void logit(std::string output) {
//std::cout << "\033[1;31m" << output << "\033[0m" << std::endl; std::cout << "\033[1;31m" << output << "\033[0m" << std::endl;
} }
template <typename T> template <typename T>
@ -478,20 +478,19 @@ public:
/// Parses the command line - throws errors /// Parses the command line - throws errors
void parse(int argc, char **argv) { void parse(int argc, char **argv) {
std::vector<std::string> args; std::vector<std::string> args;
for(int i=1; i<argc; i++) for(int i=argc-1; i>0; i--)
args.emplace_back(argv[i]); args.push_back(argv[i]);
parse(args); parse(args);
} }
void parse(std::vector<std::string> args) { void parse(std::vector<std::string> args) {
parsed = true; parsed = true;
std::reverse(args.begin(), args.end());
bool positional_only = false; bool positional_only = false;
while(args.size()>0) { while(args.size()>0) {
logit(join(args)); logit("Parse: ["+join(args)+"]");
Classifer classifer = positional_only ? Classifer::NONE : _recognize(args.back()); Classifer classifer = positional_only ? Classifer::NONE : _recognize(args.back());
switch(classifer) { switch(classifer) {