36 lines
728 B
C++
36 lines
728 B
C++
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace dts {
|
|
|
|
struct ProcessRequest {
|
|
std::filesystem::path program;
|
|
std::vector<std::string> arguments;
|
|
std::filesystem::path workingDirectory;
|
|
std::chrono::milliseconds timeout{10000};
|
|
};
|
|
|
|
struct ProcessResult {
|
|
bool started = false;
|
|
bool timedOut = false;
|
|
int exitCode = -1;
|
|
std::string output;
|
|
std::string error;
|
|
};
|
|
|
|
class IProcessRunner {
|
|
public:
|
|
virtual ~IProcessRunner() = default;
|
|
[[nodiscard]] virtual ProcessResult run(const ProcessRequest& request) const = 0;
|
|
};
|
|
|
|
[[nodiscard]] std::unique_ptr<IProcessRunner> createDefaultProcessRunner();
|
|
|
|
} // namespace dts
|
|
|