forked from qt-creator/qt-creator
VcsBase: Add a convenience function execBgCommand
Creates and executes a command asynchronously, passing its stdout to a callback function. Change-Id: I6be7e803fadf708ca7dc587b612a5a63e9bf09c3 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
71ba0b8853
commit
5d14d127d7
@@ -108,6 +108,22 @@ VcsCommand *VcsBaseClientImpl::createCommand(const FilePath &workingDirectory,
|
||||
return cmd;
|
||||
}
|
||||
|
||||
VcsCommand *VcsBaseClientImpl::execBgCommand(const FilePath &workingDirectory,
|
||||
const QStringList &args,
|
||||
const std::function<void (const QString &)> &outputCallback,
|
||||
unsigned flags) const
|
||||
{
|
||||
VcsCommand *cmd = createCommand(workingDirectory);
|
||||
cmd->addFlags(flags
|
||||
| VcsCommand::SuppressCommandLogging
|
||||
| VcsCommand::SuppressStdErr
|
||||
| VcsCommand::SuppressFailMessage);
|
||||
cmd->addJob({vcsBinary(), args});
|
||||
connect(cmd, &VcsCommand::stdOutText, this, outputCallback);
|
||||
cmd->execute();
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||
const ExitCodeInterpreter &interpreter) const
|
||||
{
|
||||
|
@@ -82,6 +82,11 @@ public:
|
||||
VcsBaseEditorWidget *editor = nullptr,
|
||||
JobOutputBindMode mode = NoOutputBind) const;
|
||||
|
||||
VcsCommand *execBgCommand(const Utils::FilePath &workingDirectory,
|
||||
const QStringList &args,
|
||||
const std::function<void (const QString &)> &outputCallback,
|
||||
unsigned flags = 0) const;
|
||||
|
||||
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||
const Utils::ExitCodeInterpreter &interpreter = {}) const;
|
||||
|
||||
|
Reference in New Issue
Block a user