| 485 | } |
| 486 | |
| 487 | std::optional<fs::path> cliFindScript(int argc, char* argv[], const std::optional<fs::path>& assetPath) { |
| 488 | if (auto script = std::getenv("DORA_CLI_SCRIPT")) { |
| 489 | if (*script) return cliAbsolutePath(script); |
| 490 | } |
| 491 | std::vector<fs::path> candidates; |
| 492 | if (assetPath) { |
| 493 | candidates.push_back(*assetPath); |
| 494 | } |
| 495 | candidates.insert(candidates.end(), { |
| 496 | fs::current_path() / "Assets", |
| 497 | fs::current_path(), |
| 498 | }); |
| 499 | if (argc > 0 && argv[0] && *argv[0]) { |
| 500 | auto exe = cliAbsolutePath(argv[0]); |
| 501 | auto exeDir = exe.parent_path(); |
| 502 | candidates.push_back(exeDir / "../Resources"); |
| 503 | candidates.push_back(exeDir / ".."); |
| 504 | } |
| 505 | for (const auto& candidate : candidates) { |
| 506 | if (auto script = cliFindScriptInRoot(candidate)) { |
| 507 | return script; |
| 508 | } |
| 509 | } |
| 510 | return std::nullopt; |
| 511 | } |
| 512 | |
| 513 | int runCliApplication(int argc, char* argv[]) { |
| 514 | auto cliIndex = cliCommandIndex(argc, argv); |
no test coverage detected