Commit c1329572 authored by Kenton Varda's avatar Kenton Varda

Treat '-' as a regular argument rather than an option flag.

parent 8a2bd42f
......@@ -380,7 +380,8 @@ void MainBuilder::MainImpl::operator()(StringPtr programName, ArrayPtr<const Str
KJ_IF_MAYBE(error, (*option.funcWithArg)(*arg).releaseError()) {
usageError(programName, str(param, ": ", *error));
}
} else if (i + 1 < params.size() && !params[i + 1].startsWith("-")) {
} else if (i + 1 < params.size() &&
!(params[i + 1].startsWith("-") && params[i + 1].size() > 1)) {
// "--foo blah": "blah" is the argument.
++i;
KJ_IF_MAYBE(error, (*option.funcWithArg)(params[i]).releaseError()) {
......@@ -400,7 +401,7 @@ void MainBuilder::MainImpl::operator()(StringPtr programName, ArrayPtr<const Str
}
}
}
} else if (param.startsWith("-")) {
} else if (param.startsWith("-") && param.size() > 1) {
// Short option(s).
for (uint j = 1; j < param.size(); j++) {
char c = param[j];
......@@ -418,7 +419,8 @@ void MainBuilder::MainImpl::operator()(StringPtr programName, ArrayPtr<const Str
usageError(programName, str("-", c, " ", arg, ": ", *error));
}
break;
} else if (i + 1 < params.size() && !params[i + 1].startsWith("-")) {
} else if (i + 1 < params.size() &&
!(params[i + 1].startsWith("-") && params[i + 1].size() > 1)) {
// Next parameter is argument.
++i;
KJ_IF_MAYBE(error, (*option.funcWithArg)(params[i]).releaseError()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment