Fixes issue #6

This commit is contained in:
Pranav Srinivas Kumar 2019-04-18 22:42:43 -04:00
parent 0b1a5b71f8
commit 88eca55b06

View File

@ -556,6 +556,7 @@ class ArgumentParser {
// The user provides ./main -aux ...
// Here -aux is a compound optional argument
std::string tCompoundArgument = std::string(argv[i]);
if (tCompoundArgument.size() > 1 && tCompoundArgument[0] == '-' && tCompoundArgument[1] != '-') {
for (size_t j = 1; j < tCompoundArgument.size(); j++) {
std::string tArgument(1, tCompoundArgument[j]);
size_t tNumArgs = 0;
@ -575,9 +576,18 @@ class ArgumentParser {
parse_args_internal(tArgumentsForRecursiveParsing);
}
}
else {
std::cout << "warning: unrecognized optional argument " << tCompoundArgument << std::endl;
}
}
else {
// This is a positional argument.
// Parse and save into mPositionalArguments vector
if (mNextPositionalArgument >= mPositionalArguments.size()) {
std::cout << "error: unexpected positional argument " << argv[i] << std::endl;
print_help();
exit(0);
}
auto tArgument = mPositionalArguments[mNextPositionalArgument];
auto tCount = tArgument->mNumArgs - tArgument->mRawValues.size();
while (tCount > 0) {