MCPcopy Create free account
hub / github.com/ClassicOldSong/Apollo / parse

Function parse

src/config.cpp:1387–1443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1385 }
1386
1387 int parse(int argc, char *argv[]) {
1388 std::unordered_map<std::string, std::string> cmd_vars;
1389#ifdef _WIN32
1390 bool shortcut_launch = false;
1391 bool service_admin_launch = false;
1392#endif
1393
1394 for (auto x = 1; x < argc; ++x) {
1395 auto line = argv[x];
1396
1397 if (line == "--help"sv) {
1398 logging::print_help(*argv);
1399 return 1;
1400 }
1401#ifdef _WIN32
1402 else if (line == "--shortcut"sv) {
1403 shortcut_launch = true;
1404 } else if (line == "--shortcut-admin"sv) {
1405 service_admin_launch = true;
1406 }
1407#endif
1408 else if (*line == '-') {
1409 if (*(line + 1) == '-') {
1410 sunshine.cmd.name = line + 2;
1411 sunshine.cmd.argc = argc - x - 1;
1412 sunshine.cmd.argv = argv + x + 1;
1413
1414 break;
1415 }
1416 if (apply_flags(line + 1)) {
1417 logging::print_help(*argv);
1418 return -1;
1419 }
1420 } else {
1421 auto line_end = line + strlen(line);
1422
1423 auto pos = std::find(line, line_end, '=');
1424 if (pos == line_end) {
1425 sunshine.config_file = line;
1426 } else {
1427 TUPLE_EL(var, 1, parse_option(line, line_end));
1428 if (!var) {
1429 logging::print_help(*argv);
1430 return -1;
1431 }
1432
1433 TUPLE_EL_REF(name, 0, *var);
1434
1435 auto it = cmd_vars.find(name);
1436 if (it != std::end(cmd_vars)) {
1437 cmd_vars.erase(it);
1438 }
1439
1440 cmd_vars.emplace(std::move(*var));
1441 }
1442 }
1443 }
1444

Callers

nothing calls this directly

Calls 3

apply_flagsFunction · 0.85
moveFunction · 0.85
print_helpFunction · 0.70

Tested by

no test coverage detected