in src/unix-adapter/main.cc [480:532]
static void parseArguments(int argc, char *argv[], Arguments &out)
{
out.mouseInput = false;
out.testAllowNonTtys = false;
out.testConerr = false;
out.testPlainOutput = false;
out.testColorEscapes = false;
bool doShowKeys = false;
const char *const program = argc >= 1 ? argv[0] : "<program>";
int argi = 1;
while (argi < argc) {
std::string arg(argv[argi++]);
if (arg.size() >= 1 && arg[0] == '-') {
if (arg == "-h" || arg == "--help") {
usage(program, 0);
} else if (arg == "--mouse") {
out.mouseInput = true;
} else if (arg == "--showkey") {
doShowKeys = true;
} else if (arg == "--version") {
dumpVersionToStdout();
exit(0);
} else if (arg == "-Xallow-non-tty") {
out.testAllowNonTtys = true;
} else if (arg == "-Xconerr") {
out.testConerr = true;
} else if (arg == "-Xplain") {
out.testPlainOutput = true;
} else if (arg == "-Xcolor") {
out.testColorEscapes = true;
} else if (arg == "--") {
break;
} else {
fprintf(stderr, "Error: unrecognized option: '%s'\n",
arg.c_str());
exit(1);
}
} else {
out.childArgv.push_back(arg);
break;
}
}
for (; argi < argc; ++argi) {
out.childArgv.push_back(argv[argi]);
}
if (doShowKeys) {
debugShowKey(out.testAllowNonTtys);
exit(0);
}
if (out.childArgv.size() == 0) {
usage(program, 1);
}
}