MCPcopy Create free account
hub / github.com/clMathLibraries/clBLAS / parseCommandLine

Method parseCommandLine

src/library/tools/ktest/config-cmdline.cpp:227–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227bool
228Config::parseCommandLine(int argc, char *argv[])
229{
230
231 po::options_description helpOpts("Application Arguments");
232 helpOpts.add_options()
233 ("config", po::value<std::string>()->default_value(defaultConfig_),
234 "Configuration file")
235 ("help,h", "Show this help message");
236 po::options_description visibleOpts;
237 visibleOpts.add(helpOpts);
238 setOptDesc(visibleOpts, true);
239
240 try {
241 po::store(po::parse_command_line(argc, argv, visibleOpts), vm);
242 po::notify(vm);
243 }
244 catch (const po::invalid_command_line_syntax &err) {
245#if BOOST_VERSION >= 104200
246 switch (err.kind()) {
247 case po::invalid_syntax::missing_parameter:
248 std::cerr << "Missing argument for option `" << err.tokens()
249 << "'" << std::endl;
250 break;
251 default:
252 std::cerr << "Syntax error, kind " << int(err.kind())
253 << std::endl;
254 break;
255 };
256#else
257 std::cerr << err.msg;
258#endif
259 return false;
260 }
261 catch (const po::validation_error &err) {
262 std::cerr << err.what() << std::endl;
263 return false;
264 }
265 catch (const po::unknown_option &err) {
266 std::cerr << err.what() << std::endl;
267 }
268
269 if (vm.count("help")) {
270 std::cout << visibleOpts << std::endl;
271 return false;
272 }
273 if (vm.count("config")) {
274 loadConfig(vm["config"].as<std::string>().c_str());
275 }
276
277 return applyOptions(vm);
278}
279
280bool
281Config::applyOptions(

Callers 1

mainFunction · 0.80

Calls 1

addMethod · 0.80

Tested by

no test coverage detected