本文整理汇总了C++中ArgParser::parseArg方法的典型用法代码示例。如果您正苦于以下问题:C++ ArgParser::parseArg方法的具体用法?C++ ArgParser::parseArg怎么用?C++ ArgParser::parseArg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArgParser
的用法示例。
在下文中一共展示了ArgParser::parseArg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xcrun
int xcrun(int argc, char **argv, Target &target) {
if (getenv("xcrun_log"))
showCommand = true;
constexpr const char *ENVVARS[] = {
"DEVELOPER_DIR", "TOOLCHAINS", "xcrun_verbose"
};
for (const char *evar : ENVVARS) {
if (getenv(evar)) {
warn << "xcrun: ignoring environment variable "
<< "'" << evar << "'" << warn.endl();
}
}
if (char *SDK = getenv("SDKROOT")) {
unsetenv("OSXCROSS_SDKROOT");
char *argv[1] = { SDK };
sdk(target, argv);
}
auto dummy = [](Target&, char**) { return 0; };
ArgParser<int (*)(Target&, char**), 19> argParser = {{
{"h", help},
{"help", help},
{"version", version},
{"v", dummy},
{"verbose", dummy},
{"k", dummy},
{"kill-cache", dummy},
{"n", dummy},
{"no-cache", dummy},
{"sdk", sdk, 1},
{"toolchain", dummy, 1},
{"l", log },
{"log", log},
{"f", find, 1},
{"find", find, 1},
{"r", run, 1},
{"run", run, 1},
{"show-sdk-path", showSDKPath},
{"show-sdk-version", showSDKVersion}
}};
int retVal = 1;
for (int i = 1; i < argc; ++i) {
auto b = argParser.parseArg(argc, argv, i);
if (!b) {
if (argv[i][0] == '-') {
err << "xcrun: unknown argument: '" << argv[i] << "'" << err.endl();
retVal = 2;
break;
}
run(target, &argv[i]);
}
retVal = b->fun(target, &argv[i + 1]);
if (retVal != 0)
break;
i += b->numArgs;
}
return retVal;
}