MCPcopy Create free account
hub / github.com/apache/thrift / parse_args

Function parse_args

lib/cpp/test/TFileTransportTest.cpp:350–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350void parse_args(int argc, char* argv[]) {
351 struct option long_opts[]
352 = {{"help", false, nullptr, 'h'}, {"tmp-dir", true, nullptr, 't'}, {nullptr, 0, nullptr, 0}};
353
354 while (true) {
355 optopt = 1;
356 int optchar = getopt_long(argc, argv, "ht:", long_opts, nullptr);
357 if (optchar == -1) {
358 break;
359 }
360
361 switch (optchar) {
362 case 't':
363 tmp_dir = optarg;
364 break;
365 case 'h':
366 print_usage(stdout, argv[0]);
367 exit(0);
368 case '?':
369 exit(1);
370 default:
371 // Only happens if someone adds another option to the optarg string,
372 // but doesn't update the switch statement to handle it.
373 fprintf(stderr, "unknown option \"-%c\"\n", optchar);
374 exit(1);
375 }
376 }
377}
378
379#ifdef BOOST_TEST_DYN_LINK
380static int myArgc = 0;

Callers 1

init_unit_test_suiteFunction · 0.85

Calls 1

print_usageFunction · 0.70

Tested by

no test coverage detected