| 455 | } |
| 456 | |
| 457 | std::optional<fs::path> cliFindScriptInRoot(const fs::path& root) { |
| 458 | std::error_code err; |
| 459 | auto base = fs::weakly_canonical(root, err); |
| 460 | if (err) base = root; |
| 461 | if (!fs::is_directory(base, err)) return std::nullopt; |
| 462 | for (const auto& candidate : {base / "Script" / "Dev" / "cli.lua", base / "cli.lua"}) { |
| 463 | if (fs::is_regular_file(candidate, err)) { |
| 464 | return fs::weakly_canonical(candidate, err); |
| 465 | } |
| 466 | err.clear(); |
| 467 | } |
| 468 | for (auto it = fs::recursive_directory_iterator(base, fs::directory_options::skip_permission_denied, err); it != fs::recursive_directory_iterator(); it.increment(err)) { |
| 469 | if (err) { |
| 470 | err.clear(); |
| 471 | continue; |
| 472 | } |
| 473 | const auto& entry = *it; |
| 474 | if (entry.is_directory(err)) { |
| 475 | if (cliSkipEntrySearchDir(entry.path())) { |
| 476 | it.disable_recursion_pending(); |
| 477 | } |
| 478 | continue; |
| 479 | } |
| 480 | if (entry.is_regular_file(err) && entry.path().filename() == "cli.lua") { |
| 481 | return fs::weakly_canonical(entry.path(), err); |
| 482 | } |
| 483 | } |
| 484 | return std::nullopt; |
| 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")) { |
no test coverage detected