4#include <QProcessEnvironment>
42 void setCwd(
const QString& path);
51 using FinshedCallback = std::function<void(
int,
const QString&)>;
52 using LogCallback = std::function<void(
const QString&)>;
61 int runSync(
const QString& cmd, QString& result);
71 void runAsync(
const QString& cmd, FinshedCallback finishedCb, LogCallback stdoutCb =
nullptr, LogCallback stderrCb =
nullptr);
80 static int ExecuteSync(
const QString& cmd, QString& result);
91 static void ExecuteAsync(
const QString& cmd, QObject* parent,
92 FinshedCallback finishedCb, LogCallback stdoutCb =
nullptr, LogCallback stderrCb =
nullptr);
95 QProcessEnvironment mEnv;
static int ExecuteSync(const QString &cmd, QString &result)
Runs a command synchronously and returns the result.
Definition process_runner.cpp:122
int runSync(const QString &cmd, QString &result)
Runs a command synchronously and returns the result.
Definition process_runner.cpp:35
void addEnvVariable(const QString &key, const QString &value)
Adds an environment variable to the process.
Definition process_runner.cpp:14
void setTimeout(int ms)
Sets the timeout for the process in milliseconds.
Definition process_runner.cpp:30
void runAsync(const QString &cmd, FinshedCallback finishedCb, LogCallback stdoutCb=nullptr, LogCallback stderrCb=nullptr)
Runs a command asynchronously with callbacks for finished and logging.
Definition process_runner.cpp:77
QString mCwd
Environment variables for the process.
Definition process_runner.h:96
void setCwd(const QString &path)
Sets the current working directory for the process.
Definition process_runner.cpp:25
void removeEnvVariable(const QString &key, const QString &value)
Removes an environment variable from the process.
Definition process_runner.cpp:19
int mTimeout
Current working directory for the process.
Definition process_runner.h:97
ProcessRunner(QObject *parent=nullptr)
Constructs a new ProcessRunner object.
Definition process_runner.cpp:8
static void ExecuteAsync(const QString &cmd, QObject *parent, FinshedCallback finishedCb, LogCallback stdoutCb=nullptr, LogCallback stderrCb=nullptr)
Runs a command asynchronously with callbacks for finished and logging.
Definition process_runner.cpp:128