MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / runCliApplication

Function runCliApplication

Source/Basic/Application.cpp:513–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

511}
512
513int runCliApplication(int argc, char* argv[]) {
514 auto cliIndex = cliCommandIndex(argc, argv);
515 if (cliIndex < 0) {
516 std::cerr << "Dora CLI command not found.\n";
517 return 1;
518 }
519 auto asset = cliFindAssetArgument(argc, argv);
520 if (!asset.error.empty()) {
521 std::cerr << asset.error << "\n";
522 return 1;
523 }
524 auto scriptPath = cliFindScript(argc, argv, asset.path);
525 if (!scriptPath) {
526 std::cerr << "Dora CLI script cli.lua not found. Set DORA_CLI_SCRIPT or run from a Dora asset root.\n";
527 return 1;
528 }
529 CliLuaState state{luaL_newstate()};
530 if (!state.L) {
531 std::cerr << "Failed to create Lua state for Dora CLI.\n";
532 return 1;
533 }
534 cliRegisterLua(state.L, argc, argv, *scriptPath, cliIndex, asset.path);
535 auto path = scriptPath->string();
536 if (luaL_loadfile(state.L, path.c_str()) != LUA_OK) {
537 std::cerr << lua_tostring(state.L, -1) << "\n";
538 return 1;
539 }
540 if (lua_pcall(state.L, 0, 1, 0) != LUA_OK) {
541 std::cerr << lua_tostring(state.L, -1) << "\n";
542 return 1;
543 }
544 int exitCode = 0;
545 if (lua_isinteger(state.L, -1)) {
546 exitCode = s_cast<int>(lua_tointeger(state.L, -1));
547 } else if (lua_isboolean(state.L, -1)) {
548 exitCode = lua_toboolean(state.L, -1) ? 0 : 1;
549 }
550 return exitCode;
551}
552
553#else // DORA_CLI_SUPPORTED
554

Callers 2

mainFunction · 0.85
WinMainFunction · 0.85

Calls 13

cliCommandIndexFunction · 0.85
cliFindAssetArgumentFunction · 0.85
cliFindScriptFunction · 0.85
luaL_newstateFunction · 0.85
cliRegisterLuaFunction · 0.85
luaL_loadfileFunction · 0.85
lua_pcallFunction · 0.85
lua_isintegerFunction · 0.85
lua_tointegerFunction · 0.85
lua_tobooleanFunction · 0.50
emptyMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected