MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ParseOptions

Function ParseOptions

src/openrct2/command_line/CommandLine.cpp:327–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325 }
326
327 static bool ParseOptions(const CommandLineOptionDefinition* options, CommandLineArgEnumerator* argEnumerator)
328 {
329 bool firstOption = true;
330
331 const char* argument;
332 while (argEnumerator->TryPopString(&argument))
333 {
334 if (HandleSpecialArgument(argument))
335 {
336 continue;
337 }
338
339 if (argument[0] == '-')
340 {
341 if (argument[1] == '-')
342 {
343 if (!ParseLongOption(options, argEnumerator, &argument[2]))
344 {
345 return false;
346 }
347 }
348 else
349 {
350 if (!ParseShortOption(options, argEnumerator, argument))
351 {
352 return false;
353 }
354 }
355 firstOption = false;
356 }
357 else if (!firstOption)
358 {
359 Console::Error::WriteLine("All options must be passed at the end of the command line.");
360 return false;
361 }
362 }
363
364 return true;
365 }
366
367 static bool ParseLongOption(
368 const CommandLineOptionDefinition* options, CommandLineArgEnumerator* argEnumerator, const char* argument)

Callers 1

CommandLineRunFunction · 0.85

Calls 5

HandleSpecialArgumentFunction · 0.85
ParseLongOptionFunction · 0.85
ParseShortOptionFunction · 0.85
WriteLineFunction · 0.85
TryPopStringMethod · 0.80

Tested by

no test coverage detected