MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / parseCommandLine

Function parseCommandLine

TheForceEngine/main.cpp:396–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396void parseCommandLine(s32 argc, char* argv[])
397{
398 if (argc < 1) { return; }
399
400 const char* curOptionName = nullptr;
401 bool longName = false;
402 std::vector<const char*> values;
403 for (s32 i = 1; i < argc; i++)
404 {
405 const char* opt = argv[i];
406 const size_t len = strlen(opt);
407
408 TFE_System::logWrite(LOG_MSG, "Main", "Parsing parameter %s", opt);
409
410 // Is this an option name or value?
411 const char* optValue = nullptr;
412 if (len && opt[0] == '-')
413 {
414 if (curOptionName)
415 {
416 parseOption(curOptionName, values, longName);
417 }
418 if (len > 2 && opt[0] == '-' && opt[1] == '-')
419 {
420 longName = true;
421 curOptionName = opt + 2;
422 }
423 else
424 {
425 longName = false;
426 curOptionName = opt + 1;
427 }
428 values.clear();
429 }
430 else if (len && opt[0] != '-')
431 {
432 values.push_back(opt);
433 }
434 }
435 if (curOptionName)
436 {
437 parseOption(curOptionName, values, longName);
438 }
439}
440
441void generateScreenshotTime()
442{

Callers 1

mainFunction · 0.85

Calls 4

logWriteFunction · 0.85
parseOptionFunction · 0.85
push_backMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected