MCPcopy Create free account
hub / github.com/apitrace/apitrace / command

Function command

cli/cli_sed.cpp:357–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355
356
357static int
358command(int argc, char *argv[])
359{
360 Replacements replacements;
361 trace::Properties extraProperties;
362 std::string outFileName;
363 trace::CallSet calls;
364
365 int opt;
366 while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
367 switch (opt) {
368 case 'h':
369 usage();
370 return 0;
371 case 'o':
372 outFileName = optarg;
373 break;
374 case 'e':
375 if (!parseSubstOpt(replacements, optarg)) {
376 std::cerr << "error: invalid replacement pattern `" << optarg << "`\n";
377 return 1;
378 }
379 break;
380 case PROPERTY_OPT:
381 {
382 const char *sep = strchr(optarg, '=');
383 if (sep == nullptr) {
384 std::cerr << "error: bad property `" << optarg << "`\n";
385 return 1;
386 }
387 std::string name(static_cast<const char *>(optarg), sep);
388 std::string value(sep + 1);
389 extraProperties[name] = value;
390 break;
391 }
392 case CALLS_OPT:
393 calls.merge(optarg);
394 break;
395 default:
396 std::cerr << "error: unexpected option `" << (char)opt << "`\n";
397 usage();
398 return 1;
399 }
400 }
401
402 if (optind >= argc) {
403 std::cerr << "error: apitrace sed requires a trace file as an argument.\n";
404 usage();
405 return 1;
406 }
407
408 if (argc > optind + 1) {
409 std::cerr << "error: extraneous arguments:";
410 for (int i = optind + 1; i < argc; i++) {
411 std::cerr << " " << argv[i];
412 }
413 std::cerr << "\n";
414 usage();

Callers

nothing calls this directly

Calls 4

parseSubstOptFunction · 0.85
sed_traceFunction · 0.85
mergeMethod · 0.80
usageFunction · 0.70

Tested by

no test coverage detected