///////////////////////////////////////////////////////////////////////////
| 472 | |
| 473 | //////////////////////////////////////////////////////////////////////////////// |
| 474 | int Hooks::callHookScript(const std::string& script, const std::vector<std::string>& input, |
| 475 | std::vector<std::string>& output) const { |
| 476 | if (_debug >= 1) Context::getContext().debug("Hook: Calling " + script); |
| 477 | |
| 478 | if (_debug >= 2) { |
| 479 | Context::getContext().debug("Hook: input"); |
| 480 | for (const auto& i : input) Context::getContext().debug(" " + i); |
| 481 | } |
| 482 | |
| 483 | std::string inputStr; |
| 484 | for (const auto& i : input) inputStr += i + "\n"; |
| 485 | |
| 486 | std::vector<std::string> args; |
| 487 | buildHookScriptArgs(args); |
| 488 | if (_debug >= 2) { |
| 489 | Context::getContext().debug("Hooks: args"); |
| 490 | for (const auto& arg : args) Context::getContext().debug(" " + arg); |
| 491 | } |
| 492 | |
| 493 | // Measure time for each hook if running in debug |
| 494 | int status; |
| 495 | std::string outputStr; |
| 496 | if (_debug >= 2) { |
| 497 | Timer timer; |
| 498 | status = execute(script, args, inputStr, outputStr); |
| 499 | Context::getContext().debugTiming(format("Hooks::execute ({1})", script), timer); |
| 500 | } else |
| 501 | status = execute(script, args, inputStr, outputStr); |
| 502 | |
| 503 | output = split(outputStr, '\n'); |
| 504 | |
| 505 | if (_debug >= 2) { |
| 506 | Context::getContext().debug("Hook: output"); |
| 507 | for (const auto& i : output) |
| 508 | if (i != "") Context::getContext().debug(" " + i); |
| 509 | |
| 510 | Context::getContext().debug(format("Hook: Completed with status {1}", status)); |
| 511 | Context::getContext().debug(" "); // Blank line |
| 512 | } |
| 513 | |
| 514 | return status; |
| 515 | } |
| 516 | |
| 517 | //////////////////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected