osiewicz / GetOptPlusPlus

C++ library for command line parameter parsing.
Other
0 stars 0 forks source link

Revisit parsing method #5

Open osiewicz opened 6 years ago

osiewicz commented 6 years ago

Currently whenever we encounter an argument we look for any parameter that can accept it (and if that's the case, we see it as valid). Unfortunately it leads to weird bugs. My idea is to add new member (possibly a pointer) of class Parser called CurrentlyParsedElement or whatever - we add arguments to that parameter until either of following conditions is not met:

  1. Argument is not in parameters AcceptedArgument vector
  2. We have already parsed maximum amount of arguments for given parameter. This might render CheckArgCount obsolete since we would try to treat 'overflowing' arguments as parameters - and that should fail, obviously.

What about parameters with no argument limit and no requirements for their arguments? (Example: list of input files for your program - you can neither have requirements nor limit here). I think we have to check all the valid parameter names and see whether our argument matches any of those. If that's the case, we stop parsing current command.

osiewicz commented 6 years ago

It should be better now. Still not perfect tho.